1

Bit of a tricky situation, I have two hiera hashes, one for the user module that I call as follow:

 $users = hiera_hash('users')
 create_resources('user',$users)

And another for the authorized_keys module, similarly called via:

$keys = hiera_hash('ssh_authorized_keys')
create_resources('ssh_authorized_key',$keys)

I then have a list of maintenance users that is used for various tasks. They are created in the same way as users, just from a different hash as they don't belong to any other groups.

Each hash contains the relevant values as the module requires.

The tricky part comes in where each user must be able to log into any maintenance users' account using their own public key.

Thus each maintenance user must receive all the keys from all the normal users into his/her authorized_keys file.

I am not using puppetdb nor Enterprise, so my goto tool for this kind of challenge, exported resources, is not available to me.

I thought about building up the file from fragments, but could not get that to work, so I tried wrangling the answer from here Iterate over a hash key/values in Puppet into a solution, but was also not successful.

Now I fear I might be barking up the wrong tree altogether...

Could someone please give me some direction?

Community
  • 1
  • 1
Werner
  • 791
  • 1
  • 6
  • 23
  • 2
    Are you aware that recent versions of Puppet can **actually iterate** over your data structures? You can replace `create_resources` with `each` loops and can do more elaborate things such as nested loops. It should make this task straight forward. – Felix Frank Oct 16 '15 at 08:58
  • That looks promising, but I cant seem to get that to work either: `$systems = ['one','two','three']` `each($systems) |$value| { notify {$value:} }` That returns: SERVER: Could not match |$value| at – Werner Oct 16 '15 at 13:25
  • 1
    Are you on Puppet 4? If not, are you on Puppet `>= 3.5` and have `parser=future` in your configuration? – Felix Frank Oct 16 '15 at 13:40
  • Ahh, I added parser=future under master, but I see in main it was also set, but to current. Thanks Felix! – Werner Oct 16 '15 at 13:45

0 Answers0