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

Safe HaskellSafe-Infered



Types used when parsing the Puppet DSL. A good knowledge of the Puppet language in required to understand them.



data TopLevelType Source

This type is used to differenciate the distinct top level types that are exposed by the DSL.



This is for node entries.


This is for defines.


This is for classes.


This one is special. It represents top level statements that are not part of a node, define or class. It is defined as spurious because it is not what you are supposed to be. Also the caching system doesn't like them too much right now.

convertTopLevel :: Statement -> Either Statement (TopLevelType, String, Statement)Source

This function returns the TopLevelType of a statement if it is either a node, class or define. It returns Nothing otherwise.

data Value Source

The Value type represents a Puppet value. It is the terminal in a puppet Expression


Literal String

String literal.

Interpolable [Value]

An interpolable string, represented as a Value list.

PuppetRegexp String

A Puppet Regexp. This is very hackish as it alters the behaviour of some functions (such as conditional values).

Double Double 
Integer Integer 
VariableReference String

Reference to a variable. The string contains what is acutally typed in the manifest.

ResourceReference String Expression 
PuppetArray [Expression] 
PuppetHash Parameters 
FunctionCall String [Expression] 

This is special and quite hackish too.


data Statement Source

The actual puppet statements


Node String ![Statement] SourcePos

This holds the node name and list of statements. | This holds the variable name and the expression that it represents.

VariableAssignment String Expression SourcePos 
Include String SourcePos 
Import String SourcePos 
Require String SourcePos 
Resource String Expression ![(Expression, Expression)] Virtuality SourcePos

This holds the resource type, name, parameter list and virtuality.

ResourceDefault String ![(Expression, Expression)] SourcePos

This is a resource default declaration, such as File {owner => 'root'; }. It holds the resource type and the list of default parameters.

ResourceOverride String Expression ![(Expression, Expression)] SourcePos

This works like Resource, but the Expression holds the resource name.

ConditionalStatement ![(Expression, [Statement])] SourcePos

The pairs hold on the left a value that is resolved as a boolean, and on the right the list of statements that correspond to this. This will be generated by if/then/else statement, but also by the case statement.

ClassDeclaration String (Maybe String) ![(String, Maybe Expression)] ![Statement] SourcePos

The class declaration holds the class name, the optional name of the class it inherits from, a list of parameters with optional default values, and the list of statements it contains.

DefineDeclaration String ![(String, Maybe Expression)] ![Statement] SourcePos

The define declaration is like the ClassDeclaration except it can't inherit from anything.

ResourceCollection String !Expression ![(Expression, Expression)] SourcePos

This is the resource collection syntax (<<| |>>). It holds the conditional expression, and an eventual list of overrides. This is important as the same token conveys two distinct Puppet concepts : resource collection and resource overrides.

VirtualResourceCollection String !Expression ![(Expression, Expression)] SourcePos

Same as ResourceCollection, but for <| |>.

DependenceChain !(String, Expression) !(String, Expression) SourcePos 
MainFunctionCall String ![Expression] SourcePos 
TopContainer ![(String, Statement)] !Statement

This is a magic statement that is used to hold the spurious top level statements that comes in the same file as the correct top level statement that is stored in the second field. The first field contains pairs of filenames and statements. This is designed so that the interpreter can know whether it has already been evaluated.