Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Last active December 15, 2015 16:59
Show Gist options
  • Save neilhwatson/5292866 to your computer and use it in GitHub Desktop.
Save neilhwatson/5292866 to your computer and use it in GitHub Desktop.
Dynamic inputs and bundlesequence without common bundles
newatson@ltipc682:~/.cfagent/inputs$ cat promises.cf
body common control
{
bundlesequence => { "first", @{first.bs} };
inputs => { "first.cf", @{first.inputs} };
}
newatson@ltipc682:~/.cfagent/inputs$ cat first.cf
bundle agent first
{
vars:
"bs" slist => { "main", "post" };
"inputs" slist => { "b.cf" };
}
newatson@ltipc682:~/.cfagent/inputs$ cat b.cf
bundle agent main
{
reports:
cfengine::
"main bundle";
}
bundle agent post
{
reports:
cfengine::
"post bundle";
}
newatson@ltipc682:~/.cfagent/inputs$ cf-agent -f ./promises.cf
R: main bundle
R: post bundle
newatson@ltipc682:~/.cfagent/inputs$ cf-promises -V
@@@
@@@ cf-promises
@ @@@ @ CFEngine Core 3.4.1
@ @@@ @
@ @@@ @
@ @
@@@
@ @
@ @
@ @
Copyright (C) CFEngine AS 2008-2012
See Licensing at http://cfengine.com/3rdpartylicenses
Interestingly, the agent seems to evaluate first secretly here:
cf3> Loaded persistent memory
cf3> ***********************************************************
cf3> -> Found a policy server (hub) on 172.26.2.4
cf3> -> Input file is outside default repository, validating it
cf3> -> Promises seem to change
cf3> -> Input file is changed since last validation, validating it
cf3> -> Verifying the syntax of the inputs...
cf3> Checking policy with command ""/home/newatson/.cfagent/bin/cf-promises" -f "./promises.cf""
cf3> > Parsing file ./promises.cf
cf3> Initiate variable convergence...
cf3> > Parsing file ./first.cf
cf3> Initiate variable convergence...
cf3> > Parsing file ./b.cf
cf3> Initiate variable convergence...
cf3> Initiate variable convergence...
Later the bundlesequence is determined and used:
cf3> Initiate variable convergence...
cf3> -> Additional class defined: am_policy_hub
cf3> -> Immunizing against parental death
cf3> -> Bundlesequence => {'first','main','post'}
cf3>
cf3> *****************************************************************
cf3> BUNDLE first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment