camptocamp / puppet-accounts

11 stars 40 forks source link

Deploying ssh public key w/o creating the user #48

Closed jschaeff closed 7 years ago

jschaeff commented 7 years ago

Hi, your module is awesome, thank you. Is there a way to deploy only some ssh keys for users tha exists ? In my case, some servers use LDAP to automaticaly create account, thus, the "useradd" command returns an error. Still, I'd like to deploy the keys. Can I call accounts::authorized_keys in some way ?

jschaeff commented 7 years ago

This is how I achieved this in puppet 4

  lookup('accounts::usergroups')['sysadmins'].each | String $user| {
    accounts::authorized_key{$user:}
  }

Explanation: Get an array of accounts::usergroups['sysadmins'] and iterate on it to realize the resource accounts::authorized_key

By the way, this module could benefit greatly from the new lookup function available in puppet 4. It would get much simpler and understandable. I'll try to work on it.