Ansible playbooks to manage a user account on a set of hosts.
These are the actions that are currently supported:
- Create a new user account and add a public ssh key to its
authorized_keys
file, with the option to allow the user to run privileged commands viasudo
- Delete an existing user account and all of its directories and files
These commands can be damaging, so always double-check the id of the user that you plan to manage!
-
You must run these playbooks as a user that has ssh access to and sudo privileges on each target host in your inventory.
-
You must create an Ansible inventory file at the root of this project containing the name or IP address of each target host on which you wish to manage users. A sample inventory file might look like this:
all: hosts: my_ungrouped_host: children: group1: hosts: my_server: my_database: group2: hosts: sample.mydomain.com: db.mydomain.com: group3: hosts: 192.168.1.5: 192.168.1.6:
-
Ansible supports more complicated inventory management. If you have a need for that, consult the Ansible documentation for more information.
-
You must create a directory
group_vars
at the root of this project that contains files with the Ansible variable values for each group specified in the inventory; for example, to specify the same values for every host in the inventory you might create a single file namedall.yml
that looks like this:allow_sudo: true ansible_become: yes username: audit ssh_public_key: "{{ lookup('aws_ssm', /ssh/public/key) }}"
ansible-playbook --inventory=inventory.yml create/playbook.yml
ansible-playbook --inventory=inventory.yml delete/playbook.yml
We welcome contributions! Please see CONTRIBUTING.md
for
details.
This project is in the worldwide public domain.
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
David Redmin - [email protected]