[augeas-devel] Achieving idempotent behavior with augeas and Puppet for managing /etc/group

Soham Chakraborty dec.soham at gmail.com
Sun May 5 15:48:10 UTC 2019


Hi,

I have a requirement where I need to add few users into a particular
group. I am using Puppet and this is very much doable with the
following code:

  augeas { 'add remote users into local group called mytestgroup':
    context => '/files/etc/group/mytestgroup',
    changes => [
      "set user[1] usera",
      "set user[2] userb",
       ],
  }

What I am wondering is that is there any way to better manage this for
ongoing maintenance. Such as looping over the users and keeping the
names of the users in an array. Also if some user leaves, I have to
remove that user from /etc/group as well. In that scenario, is that
possible to have another array in the same manifest?

Something like this:

augeas { 'add remote users into local group called mytestgroup':
  users = ['user1', 'user2', 'user3']
  del_users = ['user4', 'user5', 'user6']
  context => '/files/etc/group/mytestgroup',
  <some code to add users>
  <some code to remove users>

I am not sure about that <some code to add/remove users> part. From my
googling, I didn't come across too many examples.

Is there any better way to handle this situation?

Thanks,




More information about the augeas-devel mailing list