-
-
Save sandromello/2630219 to your computer and use it in GitHub Desktop.
How to override bundle values with passed in paramaters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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