Skip to content

Instantly share code, notes, and snippets.

@tzz
Created November 14, 2015 12:05
Show Gist options
  • Save tzz/81f0f60ea5eb973c4290 to your computer and use it in GitHub Desktop.
Save tzz/81f0f60ea5eb973c4290 to your computer and use it in GitHub Desktop.
Test CFEngine container iteration
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
vars:
"users" data => parsejson('
[
{
"name": "support",
"description": "Support user",
"uid": 1020,
"group_primary": 1,
"home_dir": "/home/support",
"shell": "/bin/bash",
"password_hash": "$1$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
{
"name": "root",
"description": "root",
"uid": 0,
"group_primary": 0,
"home_dir": "/root",
"shell": "/bin/bash",
"password_hash": "$1$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"user one",
"user two"
]
');
"uk" slist => getindices(users);
reports:
"users: $(users)";
"offset $(uk): $(users[$(uk)][name]), $(users[$(uk)][description]), $(users[$(uk)][uid]), $(users[$(uk)][group_primary]), $(users[$(uk)][home_dir]), $(users[$(uk)][shell]), $(users[$(uk)][password_hash])";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment