language-puppet-1.4.3: Tools to parse and evaluate the Puppet DSL.

Safe HaskellNone
LanguageHaskell98

Puppet.Runner

Contents

Description

At the top of the abstraction level, the module exposes all high-end services:

  • the preferences container
  • the puppet daemon
  • the statistic module
  • the stdlib functions
  • a bunch of pure runners

Naturally nothing from Puppet.Runner should be used in lower abstraction layers.

Synopsis

Preferences

dfPreferences :: FilePath -> IO (Preferences IO) Source #

Generate default preferences.

Pure

dummyEval :: InterpreterMonad a -> Either PrettyError a Source #

A default evaluation function for arbitrary interpreter actions. Unlike pureEval, each hiera lookup is evaluated to return the string dummy.

dummyFacts :: Facts Source #

A bunch of facts that can be used for pure evaluation.

pureEval Source #

Arguments

:: HashMap (TopLevelType, Text) Statement

A top-level map

-> InterpreterMonad a

The action to evaluate

-> (Either PrettyError a, InterpreterState, InterpreterWriter) 

Evaluates with a map of statements in a pure context. Unlike dummyEval, each hiera lookup is evaluated to return Nothing.

pureEval' Source #

Arguments

:: HashMap (TopLevelType, Text) Statement

A top-level map

-> InterpreterState

the initial state

-> Maybe PValue

a value to be return by all hiera lookup

-> InterpreterMonad a

The action to evaluate

-> (Either PrettyError a, InterpreterState, InterpreterWriter) 

More flexible version of pureEval

pureReader Source #

Arguments

:: HashMap (TopLevelType, Text) Statement

A top-level statement map

-> Maybe PValue

What value a call to hiera should return

-> InterpreterReader Identity 

A pure InterpreterReader, that can only evaluate a subset of the templates, and that can include only the supplied top level statements.

Stats

measure Source #

Arguments

:: MStats

Statistics container

-> Text

Action identifier

-> IO a

Computation

-> IO a 

Wraps a computation, and measures related execution statistics.

newStats :: IO MStats Source #

Create a new statistical container.

getStats :: MStats -> IO StatsTable Source #

Returns the actual statistical values.

data StatsPoint Source #

Constructors

StatsPoint 

Fields

Instances
Show StatsPoint Source # 
Instance details

Defined in Puppet.Runner.Stats

Sdlib

stdlibFunctions :: Container ([PValue] -> InterpreterMonad PValue) Source #

Contains the implementation of the StdLib functions.

Daemon

data Daemon Source #

API for the Daemon. The main method is getCatalog: given a node and a list of facts, it returns the result of the compilation. This will be either an error, or a tuple containing:

  • all the resources in this catalog
  • the dependency map
  • the exported resources
  • a list of known resources, that might not be up to date, but are here for code coverage tests.

Notes :

  • It might be buggy when top level statements that are not class/define/nodes are altered.

initDaemon :: Preferences IO -> IO Daemon Source #

Entry point to get a Daemon. It will initialize the parsing and interpretation infrastructure from the Preferences.

Cache the AST of every .pp file. It could use a bit of memory. As a comparison, it fits in 60 MB with the author's manifests, but really breathes when given 300 MB of heap space. In this configuration, even if it spawns a ruby process for every template evaluation, it is way faster than the puppet stack.

It can optionally talk with PuppetDB, by setting an URL via the prefPDB. The recommended way to set it to http://localhost:8080 and set a SSH tunnel :

ssh -L 8080:localhost:8080 puppet.host

Re-export

rubyEvaluate :: Container ScopeInformation -> ScopeName -> [RubyStatement] -> Either Doc Text Source #

Evaluate a list of ruby statements.