Skip to content

Instantly share code, notes, and snippets.

@filler
Forked from nickanderson/Run output
Created May 4, 2012 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filler/2597532 to your computer and use it in GitHub Desktop.
Save filler/2597532 to your computer and use it in GitHub Desktop.
How to override bundle values with passed in paramaters
body common control {
bundlesequence => {
"main",
};
}
bundle agent main {
vars:
# I am overriding the value for value1 in "mybundle"
"array[value1]" string => "mycustomvalue";
methods:
"any" usebundle => mybundle("main.array");
}
bundle agent mybundle(params){
vars:
redhat::
"conf[value1]"
string => "redhatvalue1",
policy => "overridable",
comment => "Default value1 for machines with context redhat";
"conf[value2]"
string => "ubuntuvalue2",
policy => "overridable",
comment => "Default value2 for machines with context redhat";
ubuntu::
"conf[value1]"
string => "ubuntuvalue1",
policy => "overridable",
comment => "Default value1 for machines with context redhat";
"conf[value2]"
string => "ubuntuvalue2",
policy => "overridable",
comment => "Default value2 for machines with context redhat";
any::
# Override default values with the passed in paramaters.
"param_keys" slist => getindices("$(params)");
"conf[$(param_keys)]"
string => "$($(params)[$(param_keys)])",
policy => "overridable";
reports:
cfengine::
"$(conf[value1]) <- this one was my value";
"$(conf[value2]) <- I didnt override this one";
}
cf-agent -KIf ./paramaterized_bundle_override_defaults.cf
R: mycustomvalue <- this one was my value
R: ubuntuvalue2 <- I didnt override this one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment