Creating Administrative Linux User Accounts: gavika.administrators
By Sudheer S
We are pleased to announce gavika.administrators.
The Ansible role provides a declarative method to create Linux
user accounts with administrative privileges. In other words, these users have sudo
access without password and are
empowered to run all commands on the system.
You might be wondering why you would need a role when you can write a couple tasks yourselves in an Ansible playbook. The reason is, Do Not Repeat Yourself(DRY). Instead of writing such tasks over and over, use the abstraction provided by the role. You just have to write some YAML declaration and be done with it. Moreover, the maintenance is outsourced to an Apache licensed open source software. The role has Molecule tests to boost your confidence.
Here’s an example:
- hosts: servers
vars:
- administrators_names: ['admin01', 'admin02']
- administrators_keys:
- username: admin01
key: /path/to/id_rsa_pub_admin01
roles:
- role: gavika.administrators
This playbook will create the users admin01
and admin02
. After creating the users, sudoers
configuration is
added to empower these users to run any command with sudo and without password. In addition, the public key from the
file /path/to/id_rsa_pub_admin01
is added to authorized_keys file of admin01
.
The role also provides a feature to remove the users. Thus providing full life-cycle methods for the administrative users in your organization.