Created
March 13, 2013 17:37
-
-
Save nickanderson/5154392 to your computer and use it in GitHub Desktop.
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 ./test_getindices_dynamic_array.cf | |
!! Duplicate selection of value for variable "idx" in scope example0 | |
!! Rule from ./test_getindices_dynamic_array.cf at/before line 28 | |
!! Duplicate selection of value for variable "idx" in scope example0 | |
!! Rule from ./test_getindices_dynamic_array.cf at/before line 28 | |
R: example0 item1 | |
R: example0 item2 | |
R: example0 item3 | |
R: example1 item1 | |
R: example1 item2 | |
R: example1 item3 | |
R: example2 item1 | |
R: example2 item2 | |
R: example2 item3 |
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 => { | |
"example0", | |
"example1", | |
"example2", | |
}; | |
} | |
bundle agent example0 | |
# This pattern was shared on the CFEngine help mailing list by cyril | |
# Thanks! | |
{ | |
vars: | |
"list" slist => { "1", "2", "3" }; | |
# Autogenerate an array instead of typing it out | |
# "array[item1]" string => "value1"; | |
# "array[item2]" string => "value2"; | |
# "array[item3]" string => "value3"; | |
"array[item$(list)]" string => "value$(list)"; | |
!idx_defined:: | |
"idx" | |
slist => { getindices("array") }, | |
handle => "$(this.bundle)_get_array_index"; | |
classes: | |
"idx_defined" expression => isvariable("idx"); | |
reports: | |
cfengine:: | |
# should report 3 times itemx where x is a list value | |
"$(this.bundle) $(idx)"; | |
} | |
bundle agent example1 | |
# This pattern was shared on the CFEngine help mailing list by cyril | |
# Thanks! | |
{ | |
vars: | |
"list" slist => { "1", "2", "3" }; | |
# Autogenerate an array instead of typing it out | |
# "array[item1]" string => "value1"; | |
# "array[item2]" string => "value2"; | |
# "array[item3]" string => "value3"; | |
"array[item$(list)]" string => "value$(list)"; | |
list_defined.!idx_defined:: | |
"idx" | |
slist => { getindices("array") }, | |
handle => "$(this.bundle)_get_array_index"; | |
classes: | |
"list_defined" | |
expression => isvariable("list"), | |
comment => "This is one way to work around 'Duplicate selection of | |
value for variable' messages. Your forcing get_array_index | |
to not be evaluated until the next pass"; | |
"idx_defined" expression => isvariable("idx"); | |
reports: | |
cfengine:: | |
# should report 3 times itemx where x is a list value | |
"$(this.bundle) $(idx)"; | |
} | |
bundle agent example2 | |
# This pattern was shared on the CFEngine help mailing list by cyril | |
# Thanks! | |
{ | |
vars: | |
"list" slist => { "1", "2", "3" }; | |
# Autogenerate an array instead of typing it out | |
# "array[item1]" string => "value1"; | |
# "array[item2]" string => "value2"; | |
# "array[item3]" string => "value3"; | |
"array[item$(list)]" string => "value$(list)"; | |
!idx_defined:: | |
"idx" | |
slist => { getindices("array") }, | |
policy => "free", | |
handle => "$(this.bundle)_get_array_index", | |
comment => "Setting policy free is another way to suppress 'Duplicate | |
selection of value for variable' messages."; | |
classes: | |
"idx_defined" expression => isvariable("idx"); | |
reports: | |
cfengine:: | |
# should report 3 times itemx where x is a list value | |
"$(this.bundle) $(idx)"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment