Ansible Role login
This role creates users, adds them to additional groups, and sets their sshd authorized_keys to allow them to login to the system.
Aditionally, a group can be added to the sudoers for password-less sudo
access.
IMPORTANT:
The default behavior of this role is that it distributes SSH keys that it knows from the host/group variables and deletes any other keys that already exist on the target system in
.ssh/authorized_keys
. This might break things. Setremove_other_sshd_authorized_keys
accordingly.
Mandatory Requirements
Install the
passlib
Python module on the Ansible Controller (dnf install python3-passlib
on Fedora).
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
The group which should be added to the sudoers for password-less |
|
|
A list of the users to be created or deleted. Subkeys:
For the usage in host_vars / group_vars (can only be used in one group at a time). |
|
Example:
# optional
login__passwordless_sudo_group: 'linuxfabrik'
login__users__host_var:
- name: 'test'
password: 'linuxfabrik'
home: '/home/linuxfabrik'
create_home: true
shell: '/bin/bash'
linger: true
primary_group: 'testgroup'
additional_groups:
- 'wheel'
- '{{ login__passwordless_sudo_group }}'
sshd_authorized_keys:
- 'ssh-ed25519 M4wt6qfbtyAaBnhSJDzoQEAOwiQM7k9lTvhYhNHJ7i6ciWH9uXJlbpbDF4Wv5lSr8t1maY test@example.com'
remove_other_sshd_authorized_keys: true
state: 'present'
system: false
- name: 'github-runner'
home: '/opt/github-runner'
state: 'present'
system: true
login__users__group_var: []
Troubleshooting
[DEPRECATION WARNING]: Encryption using the Python crypt module is deprecated. The Python crypt module is deprecated and will be removed from Python 3.13. Install the passlib library for continued encryption functionality. This feature will be removed in version 2.17.
: Make sure to install the passlib
Python module on the Ansible Controller (dnf install python3-passlib
on Fedora).