It has never been easier to deploy local user accounts on linux servers !
This set of playbooks and scripts needs you to use the "users" YAML dictionary in the params.yml
file, which will be used to manage users on one or more linux servers.
Here is a pretty simple example for dictionary fill :
users:
- name: foo
email: foo@foo.bar
shell: /bin/bash
state: present
- name: app
comment: Application user account
email: bar@foo.bar
shell: /bin/false
state: present
Users dictionary is based on Ansible's user core module. For my needs, I just included these parameters :
- user:
name: "{{ item.name }}"
password: "{{ item.encrypted_password|default(omit) }}"
comment: "{{ item.comment|default(omit) }}"
uid: "{{ item.uid|default(omit) }}"
group: "{{ item.group|default(omit) }}"
groups: "{{ item.groups|default(omit) }}"
shell: "{{ item.shell|default(omit) }}"
expires: "{{ epoch_date.stdout|default(omit) }}"
state: "{{ item.state }}"
Feel free to adapt it as you needs ;-)
Don't worry about password fields, they will be automatically generated !
NB: For my needs, I had to use expires date but you can delete / ignore it.
ansible-playbook global.yml -i inventories/production
Or
ansible-playbook global.yml -i inventories/production -u ssh_username -k -K
Once the playbook has been successfully executed, an email will be sent to the user with his credentials.