-- 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.4.0 -- | A quickly done module that exports utility functions used to collect -- various statistics. All statistics are stored in a MVar holding a Map. module Puppet.Stats data StatsPoint StatsPoint :: !Int -> !Double -> !Double -> !Double -> StatsPoint type StatsTable = Map Text StatsPoint type MStats = MVar StatsTable getStats :: MStats -> IO StatsTable newStats :: IO MStats measure :: MStats -> Text -> IO a -> IO a measure_ :: MStats -> Text -> IO a -> IO () getTime :: IO Double time :: IO a -> IO (Double, a) instance Show StatsPoint -- | 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, Text, Statement) -- | The Value type represents a Puppet value. It is the terminal in -- a puppet Expression data Value -- | String literal. Literal :: !Text -> 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 :: !Text -> Value Double :: !Double -> Value Integer :: !Integer -> Value -- | Reference to a variable. The string contains what is acutally typed in -- the manifest. VariableReference :: !Text -> Value Empty :: Value ResourceReference :: !Text -> !Expression -> Value PuppetArray :: ![Expression] -> Value PuppetHash :: !Parameters -> Value FunctionCall :: !Text -> ![Expression] -> Value PuppetBool :: Bool -> 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 :: Text -> ![Statement] -> !SourcePos -> Statement VariableAssignment :: !Text -> !Expression -> !SourcePos -> Statement Include :: !Expression -> !SourcePos -> Statement Import :: !Text -> !SourcePos -> Statement Require :: !Text -> !SourcePos -> Statement -- | This holds the resource type, name, parameter list and virtuality. Resource :: !Text -> !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 :: !Text -> ![(Expression, Expression)] -> !SourcePos -> Statement -- | This works like Resource, but the Expression holds the -- resource name. ResourceOverride :: !Text -> !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 :: !Text -> !(Maybe Text) -> ![(Text, Maybe Expression)] -> ![Statement] -> !SourcePos -> Statement -- | The define declaration is like the ClassDeclaration except it -- can't inherit from anything. DefineDeclaration :: !Text -> ![(Text, 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 :: !Text -> !Expression -> ![(Expression, Expression)] -> !SourcePos -> Statement -- | Same as ResourceCollection, but for <| |>. VirtualResourceCollection :: !Text -> !Expression -> ![(Expression, Expression)] -> !SourcePos -> Statement DependenceChain :: !(Text, Expression) -> !(Text, Expression) -> !SourcePos -> Statement MainFunctionCall :: !Text -> ![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 :: ![(Text, 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 -- | NegOperation :: !Expression -> Expression -- | a ? b (b should be a PuppetHash) ConditionalValue :: !Expression -> !Expression -> Expression -- | Value terminal Value :: !Value -> Expression -- | Resolved resource reference ResolvedResourceReference :: !Text -> !Text -> Expression -- | True expression, this could have been better to use a Value BTrue :: Expression -- | False expression BFalse :: Expression capitalizeResType :: Text -> Text capitalize' :: Text -> Text instance Show TopLevelType instance Ord TopLevelType instance Eq TopLevelType instance Show Virtuality instance Ord Virtuality instance Eq Virtuality instance Show Expression instance Ord Expression instance Eq Expression instance Show Value instance Ord Value instance Eq Value instance Show Parameters instance Ord Parameters instance Eq Parameters instance Show Statement instance Ord Statement instance Eq Statement instance IsString Expression instance IsString Value module Puppet.DSL.Printer -- | This shows the parsed AST a bit like the original syntax. showAST :: [Statement] -> String -- | Useful for displaying a map of variables. showVarMap :: Map String (Expression, SourcePos) -> String module PuppetDB.Query data Operator OEqual :: Operator OOver :: Operator OUnder :: Operator OOverE :: Operator OUnderE :: Operator OAnd :: Operator OOr :: Operator ONot :: Operator data Query Query :: Operator -> [Query] -> Query Term :: Text -> Query Terms :: [Text] -> Query -- | Query used for realizing a resources, when its type and title is -- known. queryRealize :: Text -> Text -> Query -- | Collects all resources of a given type collectAll :: Text -> Query -- | Collections based on tags. collectTag :: Text -> Text -> Query -- | Used to emulate collections such as `Typeprmname == "prmval" -- ||` collectParam :: Text -> Text -> Text -> Query showOperator :: Operator -> Text getOperator :: Text -> Maybe Operator showQuery :: Query -> Text instance Show Operator instance Ord Operator instance Eq Operator instance Show Query instance Ord Query instance Eq Query module Puppet.Interpreter.Types -- | Types for the native type system. type PuppetTypeName = Text -- | 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 Text -> PuppetTypeMethods puppetvalidate :: PuppetTypeMethods -> PuppetTypeValidate puppetfields :: PuppetTypeMethods -> Set Text -- | This is the potentially unsolved list of resources in the catalog. type Catalog = [CResource] type Facts = Map Text ResolvedValue -- | Relationship link type. data LinkType RNotify :: LinkType RRequire :: LinkType RBefore :: LinkType RSubscribe :: LinkType type LinkInfo = (LinkType, RelUpdateType, SourcePos, [[ScopeName]]) -- | The list of resolved values that are used to define everything in a -- FinalCatalog and in the resolved parts of a Catalog. -- They are to be compared with the Values. data ResolvedValue ResolvedString :: !Text -> ResolvedValue ResolvedRegexp :: !Text -> ResolvedValue ResolvedInt :: !Integer -> ResolvedValue ResolvedDouble :: !Double -> ResolvedValue ResolvedBool :: !Bool -> ResolvedValue ResolvedRReference :: !Text -> !ResolvedValue -> ResolvedValue ResolvedArray :: ![ResolvedValue] -> ResolvedValue ResolvedHash :: ![(Text, ResolvedValue)] -> ResolvedValue ResolvedUndefined :: ResolvedValue parseResourceReference :: Text -> Maybe ResolvedValue -- | This type holds a value that is either from the ASL or fully resolved. type GeneralValue = Either Expression ResolvedValue -- | This type holds a value that is either from the ASL or a fully -- resolved String. type GeneralString = Either Expression Text -- | This describes the resources before the final resolution. This is -- required as they must somehow be collected while the Statements -- are interpreted, but the necessary Expressions are not yet -- available. This is because in Puppet the Statement order should -- not alter the catalog's content. -- -- The relations are not stored here, as they are pushed into a separate -- internal data structure by the interpreter. data CResource CResource :: !Int -> !GeneralString -> !Text -> !(Map GeneralString GeneralValue) -> !Virtuality -> ![[ScopeName]] -> !SourcePos -> CResource -- | Resource ID, used in the Puppet YAML. crid :: CResource -> !Int -- | Resource name. crname :: CResource -> !GeneralString -- | Resource type. crtype :: CResource -> !Text -- | Resource parameters. crparams :: CResource -> !(Map GeneralString GeneralValue) -- | Resource virtuality. crvirtuality :: CResource -> !Virtuality -- | Resource scope when it was defined crscope :: CResource -> ![[ScopeName]] -- | Source code position of the resource definition. pos :: CResource -> !SourcePos -- | Used for puppetDB queries, converting values to CResources json2puppet :: FromJSON a => Value -> Either String a -- | Resource identifier, made of a type, name pair. type ResIdentifier = (Text, Text) -- | Resource relation, made of a LinkType, ResIdentifier -- pair. type Relation = (LinkType, ResIdentifier) -- | This is a fully resolved resource that will be used in the -- FinalCatalog. data RResource RResource :: !Int -> !Text -> !Text -> !(Map Text ResolvedValue) -> ![Relation] -> ![[ScopeName]] -> !SourcePos -> RResource -- | Resource ID. rrid :: RResource -> !Int -- | Resource name. rrname :: RResource -> !Text -- | Resource type. rrtype :: RResource -> !Text -- | Resource parameters. rrparams :: RResource -> !(Map Text ResolvedValue) -- | Resource relations. rrelations :: RResource -> ![Relation] -- | Resource scope when it was defined rrscope :: RResource -> ![[ScopeName]] -- | Source code position of the resource definition. rrpos :: RResource -> !SourcePos rr2json :: Text -> RResource -> Value type FinalCatalog = Map ResIdentifier RResource type ScopeName = Text -- | Type of update/override, so they can be applied in the correct order. -- This part is probably not behaving like vanilla puppet, as it turns -- out this are many fairly acceptable behaviours and the correct one is -- not documented. data RelUpdateType UNormal :: RelUpdateType UOverride :: RelUpdateType UDefault :: RelUpdateType UPlus :: RelUpdateType -- | A data type to hold defaults values data ResDefaults RDefaults :: Text -> (Map GeneralString GeneralValue) -> SourcePos -> ResDefaults ROverride :: Text -> GeneralString -> (Map GeneralString GeneralValue) -> SourcePos -> ResDefaults -- | The most important data structure for the interpreter. It stores its -- internal state. data ScopeState ScopeState :: ![[ScopeName]] -> !(Map Text (GeneralValue, SourcePos)) -> !(Map Text SourcePos) -> !(Map [ScopeName] [ResDefaults]) -> !Int -> !SourcePos -> !(Map (TopLevelType, Text) Statement) -> (TopLevelType -> Text -> IO (Either String Statement)) -> ![Text] -> ![(CResource -> CatalogMonad Bool, Map GeneralString GeneralValue, Maybe Query)] -> ![([(LinkType, GeneralValue, GeneralValue)], (Text, GeneralString), RelUpdateType, SourcePos, [[ScopeName]])] -> (Either Text Text -> Text -> Map Text GeneralValue -> IO (Either String Text)) -> (Text -> Query -> IO (Either String Value)) -> Maybe LuaState -> !(Set Text) -> !(Map PuppetTypeName PuppetTypeMethods) -> !(Map ResIdentifier SourcePos) -> [ResIdentifier] -> ScopeState -- | The list of scopes. It works like a stack, and its initial value must -- be [["::"]]. It is a stack of lists of strings. These lists -- can be one element wide (usual case), or two elements (inheritance), -- so that variables could be assigned to both scopes. curScope :: ScopeState -> ![[ScopeName]] -- | The list of known variables. It should be noted that the interpreter -- tries to resolve them as soon as it can, so that it can store their -- current scope. curVariables :: ScopeState -> !(Map Text (GeneralValue, SourcePos)) -- | The list of classes that have already been included, along with the -- place where this happened. curClasses :: ScopeState -> !(Map Text SourcePos) -- | List of defaults to apply. All defaults are applied at the end of the -- interpretation of each top level statement. curDefaults :: ScopeState -> !(Map [ScopeName] [ResDefaults]) -- | Stores the value of the current crid. curResId :: ScopeState -> !Int -- | Current position of the evaluated statement. This is mostly used to -- give useful error messages. curPos :: ScopeState -> !SourcePos -- | List of "top levels" that have been parsed inside another top level. -- Their behaviour is curently non canonical as the scoping rules are -- unclear. nestedtoplevels :: ScopeState -> !(Map (TopLevelType, Text) Statement) -- | This is a function that, given the type of a top level statement and -- its name, should return it. getStatementsFunction :: ScopeState -> TopLevelType -> Text -> IO (Either String Statement) -- | List of warnings. getWarnings :: ScopeState -> ![Text] -- | A bit complicated, this stores the collection functions. These are -- functions that determine whether a resource should be collected or -- not. It can optionally store overrides, which will be applied in the -- end on all resources. It can also store a PuppetDB query. curCollect :: ScopeState -> ![(CResource -> CatalogMonad Bool, Map GeneralString GeneralValue, Maybe Query)] -- | This stores unresolved relationships, because the original string name -- can't be resolved. Fieds are [ ( [dstrelations], srcresource, type, -- pos ) ] unresolvedRels :: ScopeState -> ![([(LinkType, GeneralValue, GeneralValue)], (Text, GeneralString), RelUpdateType, SourcePos, [[ScopeName]])] -- | Function that takes either a text content or a filename, the current -- scope and a list of variables. It returns an error or the computed -- template. computeTemplateFunction :: ScopeState -> Either Text Text -> Text -> Map Text GeneralValue -> IO (Either String Text) -- | Function that takes a request type (resources, nodes, facts, ..), a -- query, and returns a resolved value from puppetDB. puppetDBFunction :: ScopeState -> Text -> Query -> IO (Either String Value) -- | The Lua state, used for user supplied content. luaState :: ScopeState -> Maybe LuaState -- | The list of registered user functions userFunctions :: ScopeState -> !(Set Text) -- | The list of native types. nativeTypes :: ScopeState -> !(Map PuppetTypeName PuppetTypeMethods) -- | Horrible hack to kind of support the defined function definedResources :: ScopeState -> !(Map ResIdentifier SourcePos) currentDependencyStack :: ScopeState -> [ResIdentifier] -- | The monad all the interpreter lives in. It is ErrorT with a -- state. type CatalogMonad = ErrorT Text (StateT ScopeState IO) -- | This is the map of all edges associated with the FinalCatalog. -- The key is (source, target). type EdgeMap = Map (ResIdentifier, ResIdentifier) LinkInfo generalizeValueE :: Expression -> GeneralValue generalizeValueR :: ResolvedValue -> GeneralValue generalizeStringE :: Expression -> GeneralString generalizeStringS :: Text -> GeneralString -- | This is the set of meta parameters metaparameters :: Set Text getPos :: ErrorT Text (StateT ScopeState IO) SourcePos modifyScope :: ([[ScopeName]] -> [[ScopeName]]) -> ScopeState -> ScopeState modifyDeps :: ([ResIdentifier] -> [ResIdentifier]) -> ScopeState -> ScopeState modifyVariables :: (Map Text (GeneralValue, SourcePos) -> Map Text (GeneralValue, SourcePos)) -> ScopeState -> ScopeState modifyClasses :: (Map Text SourcePos -> Map Text SourcePos) -> ScopeState -> ScopeState incrementResId :: ScopeState -> ScopeState setStatePos :: SourcePos -> ScopeState -> ScopeState pushWarning :: Text -> ScopeState -> ScopeState pushCollect :: (CResource -> CatalogMonad Bool, Map GeneralString GeneralValue, Maybe Query) -> ScopeState -> ScopeState pushUnresRel :: ([(LinkType, GeneralValue, GeneralValue)], (Text, GeneralString), RelUpdateType, SourcePos, [[ScopeName]]) -> ScopeState -> ScopeState addDefinedResource :: MonadState ScopeState m => ResIdentifier -> SourcePos -> m () saveVariables :: MonadState ScopeState m => Map Text (GeneralValue, SourcePos) -> m () showScope :: [[ScopeName]] -> Text throwPosError :: Text -> CatalogMonad a addAlias :: Text -> RResource -> Either String RResource insertparam :: RResource -> Text -> ResolvedValue -> RResource instance Show LinkType instance Ord LinkType instance Eq LinkType instance Show ResolvedValue instance Eq ResolvedValue instance Ord ResolvedValue instance Show RResource instance Ord RResource instance Eq RResource instance Show CResource instance Show RelUpdateType instance Ord RelUpdateType instance Eq RelUpdateType instance Show ResDefaults instance Ord ResDefaults instance Eq ResDefaults instance Error Text instance FromJSON CResource instance FromJSON ResolvedValue instance ToJSON ResolvedValue instance IsString ResolvedValue -- | These are the function and data types that are used to define the -- Puppet native types. module Puppet.NativeTypes.Helpers 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 Text -> PuppetTypeValidate -- | This validator checks that no unknown parameters have been set (except -- metaparameters) checkParameterList :: Set Text -> PuppetTypeValidate -- | This validator always accept the resources, but add the default -- parameters (such as title). addDefaults :: PuppetTypeValidate -- | Helper function that runs a validor on a ResolvedArray runarray :: Text -> (Text -> 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 :: Text -> PuppetTypeValidate strings :: Text -> PuppetTypeValidate string' :: Text -> ResolvedValue -> PuppetTypeValidate -- | Makes sure that the parameter, if defined, has a value among this -- list. values :: [Text] -> Text -> PuppetTypeValidate -- | This fills the default values of unset parameters. defaultvalue :: Text -> Text -> PuppetTypeValidate -- | Checks that a given parameter, if set, is a ResolvedInt. If it -- is a ResolvedString it will attempt to parse it. integer :: Text -> PuppetTypeValidate integers :: Text -> PuppetTypeValidate integer'' :: Text -> ResolvedValue -> PuppetTypeValidate -- | Copies the name value into the parameter if this is not set. It -- implies the string validator. nameval :: Text -> PuppetTypeValidate addAlias' :: Text -> PuppetTypeValidate -- | Checks that a given parameter is set. mandatory :: Text -> PuppetTypeValidate -- | Helper that takes a list of stuff and will generate a validator. parameterFunctions :: [(Text, [Text -> PuppetTypeValidate])] -> PuppetTypeValidate fullyQualified :: Text -> PuppetTypeValidate noTrailingSlash :: Text -> PuppetTypeValidate fullyQualifieds :: Text -> PuppetTypeValidate fullyQualified' :: Text -> ResolvedValue -> PuppetTypeValidate rarray :: Text -> PuppetTypeValidate ipaddr :: Text -> PuppetTypeValidate checkipv4 :: Text -> Int -> Bool inrange :: Integer -> Integer -> Text -> PuppetTypeValidate -- | This module holds the native Puppet resource types. module Puppet.NativeTypes -- | The map of native types. They are described in -- Puppet.NativeTypes.Helpers. baseNativeTypes :: Map PuppetTypeName PuppetTypeMethods module PuppetDB.Rest runRequest :: (FromJSON b, MonadIO m, MonadError String m) => Request (ResourceT IO) -> m b pdbRequest :: FromJSON a => Text -> Text -> Query -> IO (Either String a) rawRequest :: FromJSON a => Text -> Text -> Text -> IO (Either String a) module Puppet.Printers showRes :: CResource -> IO () showRRes :: RResource -> IO () showFCatalog :: FinalCatalog -> Text showValue :: ResolvedValue -> Text showRRef :: ResIdentifier -> Text capitalizeResType :: Text -> Text showScope :: [[ScopeName]] -> Text -- | This module is used for user plugins. It exports three functions that -- should be easy to use: initLua, puppetFunc and -- closeLua. Right now it is used by the Puppet.Daemon by -- initializing and destroying the Lua context for each catalog -- computation. Obviously such plugins will be implemented in Lua. -- -- Users plugins are right now limited to custom functions. The user must -- put them at the exact same place as their Ruby counterparts, except -- the extension must be lua instead of rb. In the file, a function -- called by the same name that takes a single argument must be defined. -- This argument will be an array made of all the functions arguments. If -- the file doesn't parse, it will be silently ignored. -- -- Here are the things that must be kept in mind: -- -- module Puppet.Plugins -- | Initializes the Lua state. The argument is the modules directory. Each -- subdirectory will be traversed for functions. The default location is -- /lib/puppet/parser/functions. initLua :: Text -> IO (LuaState, [Text]) -- | Runs a puppet function in the CatalogMonad monad. It takes a -- state, function name and list of arguments. It returns a valid Puppet -- value. puppetFunc :: LuaState -> Text -> [ResolvedValue] -> CatalogMonad ResolvedValue -- | Obviously releases the Lua state. closeLua :: LuaState -> IO () getFiles :: Text -> Text -> Text -> IO [Text] instance StackValue ResolvedValue -- | This is a helper module for the Puppet.Daemon module module Puppet.Init data Prefs Prefs :: Text -> Text -> Text -> Int -> Int -> Int -> (Text -> Query -> IO (Either String Value)) -> Map PuppetTypeName PuppetTypeMethods -> Prefs -- | The path to the manifests. manifest :: Prefs -> Text -- | The path to the modules. modules :: Prefs -> Text -- | The path to the template. templates :: Prefs -> Text -- | Size of the compiler pool. compilepoolsize :: Prefs -> Int -- | Size of the parser pool. parsepoolsize :: Prefs -> Int -- | Size of the template pool. erbpoolsize :: Prefs -> Int -- | A function that takes a query type, a query and might return stuff puppetDBquery :: Prefs -> Text -> Query -> IO (Either String Value) -- | The list of native types. natTypes :: Prefs -> Map PuppetTypeName PuppetTypeMethods -- | Generates the Prefs structure from a single path. -- --
--   genPrefs "/etc/puppet"
--   
genPrefs :: Text -> IO Prefs -- | Generates Facts from pairs of strings. -- --
--   genFacts [("hostname","test.com")]
--   
genFacts :: [(Text, Text)] -> Facts -- | 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 : -- -- module Puppet.Interpreter.Catalog -- | This function returns an error, or the FinalCatalog of -- resources to apply, the map of all edges between resources, and the -- FinalCatalog of exported resources. getCatalog :: (TopLevelType -> Text -> IO (Either String Statement)) -> (Either Text Text -> Text -> Map Text GeneralValue -> IO (Either String Text)) -> (Text -> Query -> IO (Either String Value)) -> Text -> Facts -> Maybe Text -> Map PuppetTypeName PuppetTypeMethods -> IO (Either String (FinalCatalog, EdgeMap, FinalCatalog), [Text]) module PuppetDB.TestDB initTestDBFunctions :: (Text -> Query -> IO (Either String Value)) -> IO (Text -> Query -> IO (Either String Value), Text -> (FinalCatalog, EdgeMap, FinalCatalog) -> IO ()) module Puppet.JsonCatalog prref :: ResIdentifier -> Value mkJsonCatalog :: Text -> Integer -> FinalCatalog -> FinalCatalog -> EdgeMap -> Value fakeResource :: (ResIdentifier, SourcePos) -> RResource res2JSon :: Bool -> RResource -> Value rv2json :: ResolvedValue -> Value catalog2JSon :: Text -> Integer -> FinalCatalog -> FinalCatalog -> EdgeMap -> ByteString -- | This module exports the functions that will be useful to parse the -- DSL. They should be able to parse everything you throw at them. The -- Puppet language is extremely irregular, and most valid constructs are -- not documented in the official language guide. This parser has been -- created by parsing the author's own large manifests and the public -- Wikimedia ones. -- -- Things that are known to not to be properly supported are : -- -- module Puppet.DSL.Parser -- | parse p filePath input runs a parser p over Identity -- without user state. The filePath is only used in error -- messages and may be the empty string. Returns either a -- ParseError (Left) or a value of type a -- (Right). -- --
--   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 :: Parser [Statement] -- | This is a parser for Puppet Expressions. exprparser :: ParsecT Text () 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, along with the -- dependency graph and catalog of exported resources. It also return a -- few IO functions that can be used in order to query the daemon for -- statistics, following the format in Puppet.Stats. -- -- 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. -- -- It can optionnaly talk with PuppetDB, by setting an URL in the -- Prefs data structure. The recommended way to set it to -- http:localhost:8080 and set a SSH tunnel : -- --
--   ssh -L 8080:localhost:8080 puppet.host
--   
-- -- Known bugs : -- -- initDaemon :: Prefs -> IO (Text -> Facts -> IO (Either String (FinalCatalog, EdgeMap, FinalCatalog)), IO StatsTable, IO StatsTable, IO StatsTable) module Puppet.Testing testCatalog :: Text -> FinalCatalog -> [Test] -> IO (Either String (), TestsState) data Test TestGroup :: Text -> [Test] -> Test TestFirstOk :: Text -> [Test] -> Test SingleTest :: Text -> (FinalCatalog -> TestResult) -> Test data TestsState TestsState :: Set ResIdentifier -> TestsState getCoverage :: TestsState -> Set ResIdentifier testFileSources :: Text -> FinalCatalog -> Test type TestResult = StateT TestsState IO (Either String ()) type TestMonad = ErrorT String (StateT TestsState IO) -- | Initializes a daemon made for running tests, using the specific test -- puppetDB testingDaemon :: Maybe Text -> Text -> (Text -> IO (Map Text ResolvedValue)) -> IO (Text -> IO (Either String (FinalCatalog, EdgeMap, FinalCatalog))) getFileContent :: FilePath -> RResource -> TestMonad ByteString getResource :: Text -> Text -> FinalCatalog -> TestMonad RResource fileContent :: FilePath -> Maybe Text -> Text -> (ByteString -> TestMonad ()) -> Test isEnsure :: Text -> RResource -> TestMonad () isPresent :: RResource -> TestMonad () isAbsent :: RResource -> TestMonad () checkResource :: Maybe Text -> Text -> Text -> (RResource -> TestMonad ()) -> Test checkResources :: Maybe Text -> Text -> [Text] -> (RResource -> TestMonad ()) -> Test -- | Runs a multiline regexp egrep :: Text -> ByteString -> TestMonad () sha1sum :: Text -> ByteString -> TestMonad () runTests :: Test -> FinalCatalog -> StateT TestsState IO (Either String ()) -- | Let you sequence several checks with the same input. Useful for the | -- checkResource function sequenceCheck :: [a -> TestMonad b] -> a -> TestMonad [b] -- | Same thing but without output, even more useful for the checkResource -- | function sequenceCheck_ :: [a -> TestMonad b] -> a -> TestMonad () getParameter :: Text -> RResource -> TestMonad ResolvedValue -- | Gets a resource parameter value as a (Maybe Text) getParameterM :: Text -> RResource -> TestMonad (Maybe ResolvedValue) equalOrAbsentParameter :: Text -> ResolvedValue -> RResource -> TestMonad () equalParameter :: Text -> ResolvedValue -> RResource -> TestMonad () equalParameters :: [(Text, ResolvedValue)] -> RResource -> TestMonad () (.>) :: Text -> ResolvedValue -> (Text, ResolvedValue) toByteString :: ResolvedValue -> TestMonad ByteString -- | Run tests on several hosts at once runFullTests :: [(Text -> Bool, Test)] -> [(Text, FinalCatalog)] -> IO [(Text, Either String (), TestsState)] instance Show TestsState instance Show TestR