linux_users
Ansible Role - Linux Users
This repo contains the Linux Users (linux_users) Ansible role.
What this role does
This Ansible role will create, update, and delete Linux users along with their SSH keys using the inventory.
Changes performed:
- Create management groups for the users
- Create a
sysadmins
group for password-less sudo users - Create a
sysusers
group for non-sudo users - Create a
svcaccounts
group for password-less sudo for service accounts
- Create a
- Manage root user
- Manage root's password and SSH keys
- Manage non-root users
- Create, Update, Delete user accounts
- Create, Update, Delete user home directories
- Manage user SSH keys
- Manage user group membership (It's expected to use one of the above groups)
Caveats
There are a few caveats to this role to be aware of:
- root's password should be pre-encrypted
- Using multiple SSH keys can be done in one of two ways due to the use of
exclusive: yes
:- a single string with newline characters between keys
- Pointing to a GitHub keys URL
- All non-root users will not have a password set as sudo will be password-less and they aren't expected to have local login privileges
- Users with a home directory in
/home/
that aren't defined inlinux_users.users
will be deleted- This is not the best way to manage unapproved users, and is intended to be improved upon in the future
Variables
The following variables are required:
linux_users.root_password
- The pre-encrypted password for root
The following variables are optional:
linux_users.root_key
- The SSH key(s) used by root. If left undefined then root's authorized_keys file is deletedlinux_users.users
- User objects with the following variables. If left undefined then users are not managedusers: - username: pgibbons key: "ssh-rsa BLAH BLAH BLAH" comment: Peter Gibbons group: sysadmins - username: mbolton key: https://github.com/notthatmichaelbolton.keys comment: Michael Bolton group: sysusers - username: svc-ghactions key: ssh-rsa BLAH BLAH BLAH\nssh-rsa BLEH BLEH BLEH" comment: ServiceAccount-GitHub Actions group: svcaccounts
The following variables should only be used in testing:
is_kitchen
- If this variable is defined the role(s) intests/roles
create sample users for testing unapproved user deletion against. Additionally theuser_cleanup.yml
play will exempt thevagrant
user from deletion
Testing
This role is fully tested via Test Kitchen using sample inventory data contained in this repo.
TESTING.md contains details and instructions for testing.
Donate To Support This Ansible Role
Route 1337 LLC's open source code heavily relies on donations. If you find this Ansible role useful, please consider using the GitHub Sponsors button to show your continued support.
Thank you for your support!
About
Extremely basic user account management for Ubuntu and CentOS servers
Install
ansible-galaxy install route1337/ansible-role-linuxusers
License
mit
Downloads
126
Owner
Modern InfoSec, Zero Trust, and DevOps consulting for Web2 and Web3 clients.