route1337.linux_users
Ansible Role - Linux Users
This repository has the Ansible role for managing Linux Users (linux_users).
What this role does
This role helps you create, update, and delete Linux user accounts and their SSH keys based on the provided inventory.
What it Does:
- Set up user groups:
- Create a
sysadmins
group for users who can use sudo without a password. - Create a
sysusers
group for users who cannot use sudo. - Create a
svcaccounts
group for service accounts that can use sudo without a password.
- Create a
- Manage the root user:
- Handle root's password and SSH keys.
- Manage non-root users:
- Create, update, or delete user accounts.
- Create, update, or delete home directories for users.
- Manage users’ SSH keys.
- Oversee which groups users belong to (they should be part of one of the above groups).
Caveats
Here are some important notes to remember:
- The root password must be pre-encrypted.
- You can manage multiple SSH keys in one of two ways because of
exclusive: yes
:- Use a single string with newline characters between the keys.
- Use a URL pointing to GitHub keys.
- Non-root users will not have passwords since they can use sudo without one, and they won't have local login access.
- Users who have home directories in
/home/
but are not listed inlinux_users.users
will be deleted.- This method of managing unapproved users isn't ideal and will be improved in the future.
Variables
You need to set the following required variable:
linux_users.root_password
- The already-encrypted password for the root user.
You can optionally set the following variables:
linux_users.root_key
- The SSH key(s) for the root user. If you don't define this, root's authorized_keys file will be removed.linux_users.users
- A list of user accounts with the following details. If you don’t define this, user accounts will not be managed.users: - 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 variable is mainly for testing:
is_kitchen
- If this is defined, the roles intests/roles
will create sample users for testing deletion of unapproved users. Also, theuser_cleanup.yml
play will keep thevagrant
user from being deleted.
Testing
This role has been fully tested with Test Kitchen using sample inventory data from this repository.
Please see TESTING.md for more details and instructions for testing.
Support This Ansible Role
The open-source code from Route 1337 LLC relies on donations. If you find this Ansible role useful, please consider supporting it through the GitHub Sponsors button.
Thank you for your support!
Informazioni sul progetto
Extremely basic user account management for Ubuntu and CentOS servers
Installa
ansible-galaxy install route1337.linux_users
Licenza
mit
Download
183
Proprietario
Modern InfoSec, Zero Trust, and DevOps consulting for Web2 and Web3 clients.