-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tools to parse and evaluate the Puppet DSL. -- -- This is a set of libraries designed to work with the Puppet DSL. It -- can be used to parse .pp files, compile and interpret them, evaluate -- the templates. It is still very experimental but is already pretty -- useful when working with the manifests. @package language-puppet @version 0.1.7 -- | Types used when parsing the Puppet DSL. A good knowledge of the Puppet -- language in required to understand them. module Puppet.DSL.Types data Parameters Parameters :: [(Expression, Expression)] -> Parameters -- | This type is used to differenciate the distinct top level types that -- are exposed by the DSL. data TopLevelType -- | This is for node entries. TopNode :: TopLevelType -- | This is for defines. TopDefine :: TopLevelType -- | This is for classes. TopClass :: TopLevelType -- | 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. TopSpurious :: TopLevelType -- | This function returns the TopLevelType of a statement if it is -- either a node, class or define. It returns Nothing otherwise. convertTopLevel :: Statement -> Either Statement (TopLevelType, String, Statement) -- | The Value type represents a Puppet value. It is the terminal in -- a puppet Expression data Value -- | String literal. Literal :: String -> Value -- | An interpolable string, represented as a Value list. Interpolable :: [Value] -> Value -- | A Puppet Regexp. This is very hackish as it alters the behaviour of -- some functions (such as conditional values). PuppetRegexp :: String -> Value Double :: Double -> Value Integer :: Integer -> Value -- | Reference to a variable. The string contains what is acutally typed in -- the manifest. VariableReference :: String -> Value Empty :: Value ResourceReference :: String -> Expression -> Value PuppetArray :: [Expression] -> Value PuppetHash :: Parameters -> Value FunctionCall :: String -> [Expression] -> Value -- | This is special and quite hackish too. Undefined :: Value data Virtuality Normal :: Virtuality Virtual :: Virtuality Exported :: Virtuality -- | The actual puppet statements data Statement -- | This holds the node name and list of statements. | This holds the -- variable name and the expression that it represents. Node :: String -> ![Statement] -> SourcePos -> Statement VariableAssignment :: String -> Expression -> SourcePos -> Statement Include :: String -> SourcePos -> Statement Import :: String -> SourcePos -> Statement Require :: String -> SourcePos -> Statement -- | This holds the resource type, name, parameter list and virtuality. Resource :: String -> Expression -> ![(Expression, Expression)] -> Virtuality -> SourcePos -> Statement -- | This is a resource default declaration, such as File {owner => -- 'root'; }. It holds the resource type and the list of default -- parameters. ResourceDefault :: String -> ![(Expression, Expression)] -> SourcePos -> Statement -- | This works like Resource, but the Expression holds the -- resource name. ResourceOverride :: String -> Expression -> ![(Expression, Expression)] -> SourcePos -> Statement -- | 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. ConditionalStatement :: ![(Expression, [Statement])] -> SourcePos -> Statement -- | 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. ClassDeclaration :: String -> (Maybe String) -> ![(String, Maybe Expression)] -> ![Statement] -> SourcePos -> Statement -- | The define declaration is like the ClassDeclaration except it -- can't inherit from anything. DefineDeclaration :: String -> ![(String, Maybe Expression)] -> ![Statement] -> SourcePos -> Statement -- | 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. ResourceCollection :: String -> !Expression -> ![(Expression, Expression)] -> SourcePos -> Statement -- | Same as ResourceCollection, but for <| |>. VirtualResourceCollection :: String -> !Expression -> ![(Expression, Expression)] -> SourcePos -> Statement DependenceChain :: !(String, Expression) -> !(String, Expression) -> SourcePos -> Statement MainFunctionCall :: String -> ![Expression] -> SourcePos -> 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. TopContainer :: ![(String, Statement)] -> !Statement -> Statement -- | Expressions will be described with a and b being the first and second -- field of the constructor. data Expression -- | a[b] LookupOperation :: !Expression -> !Expression -> Expression -- | a in b IsElementOperation :: !Expression -> !Expression -> Expression -- | a + b PlusOperation :: !Expression -> !Expression -> Expression -- | a - b MinusOperation :: !Expression -> !Expression -> Expression -- | a / b DivOperation :: !Expression -> !Expression -> Expression -- | a * b MultiplyOperation :: !Expression -> !Expression -> Expression -- | a << b ShiftLeftOperation :: !Expression -> !Expression -> Expression -- | a >> b ShiftRightOperation :: !Expression -> !Expression -> Expression -- | a & b AndOperation :: !Expression -> !Expression -> Expression -- | a | b OrOperation :: !Expression -> !Expression -> Expression -- | a == b EqualOperation :: !Expression -> !Expression -> Expression -- | a != b DifferentOperation :: !Expression -> !Expression -> Expression -- | a > b AboveOperation :: !Expression -> !Expression -> Expression -- | a >= b AboveEqualOperation :: !Expression -> !Expression -> Expression -- | a <= b UnderEqualOperation :: !Expression -> !Expression -> Expression -- | a < b UnderOperation :: !Expression -> !Expression -> Expression -- | a =~ b (b should be a PuppetRegexp) RegexpOperation :: !Expression -> !Expression -> Expression -- | a !~ b NotRegexpOperation :: !Expression -> !Expression -> Expression -- | ! a NotOperation :: !Expression -> Expression -- |
-- genPrefs "/etc/puppet" --genPrefs :: String -> Prefs -- | Generates Facts from pairs of strings. -- --
-- genFacts [("hostname","test.com")]
--
genFacts :: [(String, String)] -> Facts
instance Show Prefs
module Puppet.Printers
showRes :: CResource -> IO ()
showRRes :: RResource -> IO ()
showFCatalog :: FinalCatalog -> String
-- | These are the function and data types that are used to define the
-- Puppet native types.
module Puppet.NativeTypes.Helpers
type PuppetTypeName = String
-- | This is a function type than can be bound. It is the type of all
-- subsequent validators.
type PuppetTypeValidate = RResource -> Either String RResource
data PuppetTypeMethods
PuppetTypeMethods :: PuppetTypeValidate -> Set String -> PuppetTypeMethods
puppetvalidate :: PuppetTypeMethods -> PuppetTypeValidate
puppetfields :: PuppetTypeMethods -> Set String
faketype :: PuppetTypeName -> (PuppetTypeName, PuppetTypeMethods)
defaulttype :: PuppetTypeName -> (PuppetTypeName, PuppetTypeMethods)
-- | This helper will validate resources given a list of fields. It will
-- run checkParameterList and then addDefaults.
defaultValidate :: Set String -> PuppetTypeValidate
-- | This validator checks that no unknown parameters have been set (except
-- metaparameters)
checkParameterList :: Set String -> PuppetTypeValidate
-- | This validator always accept the resources, but add the default
-- parameters (such as title and name).
addDefaults :: PuppetTypeValidate
-- | Helper function that runs a validor on a ResolvedArray
runarray :: String -> (String -> ResolvedValue -> PuppetTypeValidate) -> PuppetTypeValidate
-- | This checks that a given parameter is a string. If it is a
-- ResolvedInt or ResolvedBool it will convert them to
-- strings.
string :: String -> PuppetTypeValidate
strings :: String -> PuppetTypeValidate
string' :: String -> ResolvedValue -> PuppetTypeValidate
-- | Makes sure that the parameter, if defined, has a value among this
-- list.
values :: [String] -> String -> PuppetTypeValidate
-- | This fills the default values of unset parameters.
defaultvalue :: String -> String -> PuppetTypeValidate
insertparam :: RResource -> String -> ResolvedValue -> RResource
-- | Checks that a given parameter, if set, is a ResolvedInt. If it
-- is a ResolvedString it will attempt to parse it.
integer :: String -> PuppetTypeValidate
integers :: String -> PuppetTypeValidate
integer'' :: String -> ResolvedValue -> PuppetTypeValidate
-- | Copies the name value into this if this is not set.
nameval :: String -> PuppetTypeValidate
-- | Checks that a given parameter is set.
mandatory :: String -> PuppetTypeValidate
-- | Helper that takes a list of stuff and will generate a validator.
parameterFunctions :: [(String, [String -> PuppetTypeValidate])] -> PuppetTypeValidate
fullyQualified :: String -> PuppetTypeValidate
fullyQualifieds :: String -> PuppetTypeValidate
fullyQualified' :: String -> ResolvedValue -> PuppetTypeValidate
rarray :: String -> PuppetTypeValidate
ipaddr :: String -> PuppetTypeValidate
checkipv4 :: String -> Int -> Bool
inrange :: Integer -> Integer -> String -> PuppetTypeValidate
-- | This module holds the native Puppet resource types.
module Puppet.NativeTypes
-- | The map of native types. They are described in
-- Puppet.NativeTypes.Helpers.
nativeTypes :: Map PuppetTypeName PuppetTypeMethods
-- | This module exports the getCatalog function, that computes
-- catalogs from parsed manifests. The behaviour of this module is
-- probably non canonical on many details. The problem is that most of
-- Puppet behaviour is undocumented or extremely vague. It might be
-- possible to delve into the source code or to write tests, but ruby is
-- unreadable and tests are boring.
--
-- Here is a list of known discrepencies with Puppet :
--
-- -- main = case (parse numbers "" "11, 2, 43") of -- Left err -> print err -- Right xs -> print (sum xs) -- -- numbers = commaSep integer --parse :: Stream s Identity t => Parsec s () a -> SourceName -> s -> Either ParseError a mparser :: ParsecT String u Identity [Statement] -- | This is a parser for Puppet Expressions. exprparser :: ParsecT String u Identity Expression module Puppet.DSL.Loader -- | Helper function that takes a filename and parses its content in the -- ErrorT monad. parseFile :: FilePath -> ErrorT String IO [Statement] module Puppet.Daemon -- | This is a high level function, that will initialize the parsing and -- interpretation infrastructure from the Prefs structure, and -- will return a function that will take a node name, Facts and -- return either an error or the FinalCatalog. -- -- It will internaly initialize several threads that communicate with -- channels. It should scale well, althrough it hasn't really been tested -- yet. It should cache the ASL of every .pp file, and 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 is recommended to ask for as many parser and interpreter threads as -- there are CPUs. -- -- Known bugs : -- --