I am using a list of users to define the exact set of user accounts I need on all of my managed compute instances.
For example:
users:
- {name: randy, group: admin, shell: /bin/bash, uid: 1000, sshkey: /files/users/randy_rsa.pub, … }
- {name: teresa, group: admin, shell: /bin/bash, uid: 1001, sshkey: /files/users/teresa_rsa.pub, … }
- {name: mircea, group: admin, shell: /bin/bash, uid: 1002, sshkey: /files/users/mircea_rsa.pub, … }
I would like to be able to add or remove users from this list and have the user accounts modified on all systems to match this list.
What this means is:
- If a /home/user-unwanted is found, it should be removed
- if a /home/user-wanted is not found, it should be added
otherwise, the user accounts should not be touched.
What is the best practice approach to obtaining two lists (the list of /home/* directories) and the above list in a variable file, and making only the changes needed to make these list match each other?
Thanks – Randy