language-puppet-1.3.19: 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) #

Generate default preferences.

Pure

dummyEval :: InterpreterMonad a -> Either PrettyError a #

A default evaluation function for arbitrary interpreter actions.

dummyFacts :: Facts #

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

pureEval #

Arguments

:: Facts

A list of facts that will be used during evaluation

-> HashMap (TopLevelType, Text) Statement

A top-level map

-> InterpreterMonad a

The action to evaluate

-> (Either PrettyError a, InterpreterState, InterpreterWriter) 

Evaluates an interpreter expression in a pure context.

pureEval' #

Arguments

:: HashMap (TopLevelType, Text) Statement

A top-level map

-> InterpreterState 
-> InterpreterMonad a

The action to evaluate

-> (Either PrettyError a, InterpreterState, InterpreterWriter) 

More general version of pureEval where you pass the initial state directly

pureReader #

Arguments

:: HashMap (TopLevelType, Text) Statement

A top-level statement map

-> 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 #

Arguments

:: MStats

Statistics container

-> Text

Action identifier

-> IO a

Computation

-> IO a 

Wraps a computation, and measures related execution statistics.

newStats :: IO MStats #

Create a new statistical container.

getStats :: MStats -> IO StatsTable #

Returns the actual statistical values.

data StatsPoint #

Constructors

StatsPoint 

Fields

data MStats #

Sdlib

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

Contains the implementation of the StdLib functions.

Daemon

data Daemon #

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 #

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 #

Evaluate a list of ruby statements.