Forum: CFEngine Help Subject: Trying to write an array of lists to files Author: btomasini Link to topic: https://cfengine.com/forum/read.php?3,27402,27402#msg-27402
I am working on building out a set of user skeleton directories. My approach is to have a list of keys for each user, and store each list in an array, whose key is the username. I have no problem making this work if I have a single key as a string assigned to the array element. I am not able to get it to work with an slist. Rather than having the key values show up in the files, I am getting the variable name. bundle agent users_skel_keys { vars: # This works "users" string => "key1"; # These don't: "users" slist => {"key1", "key2"}; "users" slist => {"key3", "key4"}; "index" slist => getindices("users"); files: "/var/cfengine/files/users_skel/$(index)/.ssh/." create => "true", perms => m("0700"); "/var/cfengine/files/users_skel/$(index)/.ssh/authorized_keys2" comment => "Edit authorized_keys2 files", create => "true", perms => m("0600"), edit_defaults => empty, edit_line => insert_array_lines("users_skel_keys.users[$(index)]"); } bundle edit_line insert_array_lines(v) { insert_lines: "$($(v))", comment => "Inserting key for value [$(v)]"; } Here is the console output: ubuntu@nd13:~/.cfagent/inputs/test$ sudo cf-agent -KI -f ./test_users.cf -b users_skel_keys sudo: unable to resolve host nd13 !! No commercial license file found - falling back on internal expiry !! Your configuration promises no host_licenses_paid in common control !! By doing this, you confirm that the terms of the contract are legally binding !! Unknown user $(user) in promise !! Your configuration promises no host_licenses_paid in common control !! By doing this, you confirm that the terms of the contract are legally binding >> Using command line specified bundlesequence -> Edited file /var/cfengine/files/users_skel/bob/.ssh/authorized_keys2 -> Edited file /var/cfengine/files/users_skel/joe/.ssh/authorized_keys2 ubuntu@nd13:~/.cfagent/inputs/test$ sudo cat /var/cfengine/files/users_skel/bob/.ssh/authorized_keys2 sudo: unable to resolve host nd13 $(users_skel_keys.users) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine