javiergayala.users
javiergayala.users
This is a special tool that helps you create users on servers.
Role Variables
users_list
: a list of users you want to add, with details about each user.name
: the username you want to create.groups
: a list of additional groups the user should belong to, separated by commas. Default is none.ssh_key
: the user’s public SSH key which will be added to/home/$USER/.ssh/authorized_keys
.sudoers
: if set toyes
, this user can use sudo commands on the server.sudo_opts
: options for the sudoers file.passwordless
: (True or False) defaults to "False". Change to "True" to allow sudo commands without needing a password.hosts
: defaults toALL
. The servers where this user can run sudo commands.run_as
: defaults to(ALL)
. Other users that they can run sudo commands as.commands
: defaults toALL
. The commands this user can run with sudo.requiretty
: (True or False) not set by default. Set toFalse
to remove the need for a TTY when using sudo.
user_sshkey_exclusive
: defaults tono
. Ifyes
, it means Ansible will manage the keys in theauthorized_keys
file, removing any keys not defined in this setup.use_os_prompt
: defaults tono
. Set toyes
to prevent this user from having a special bash prompt, useful for service accounts.
users_list:
- name: deployment
groups: apache
ssh_key: >
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGY
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
sudoers: "yes"
sudo_opts:
passwordless: "True"
hosts: "ALL"
run_as: "(ALL)"
commands: "ALL"
requiretty: "False"
use_os_prompt: "yes"
- name: user1
ssh_key: https://github.com/javiergayala.keys
sudoers: "no"
- name: user2
Example Playbook
- hosts: servers
roles:
- { role: javiergayala.users, users_list: [{ name: user1 }] }
Testing
To test this tool, you need:
It is highly recommended to use a virtual environment for testing:
PYENV_HOME=$WORKSPACE/.pyenv/
# Remove any previous virtual environment
if [ -d $PYENV_HOME ]; then
rm -rf $PYENV_HOME
fi
# Create a new virtual environment and install required packages
virtualenv --no-site-packages $PYENV_HOME
. $PYENV_HOME/bin/activate
pip install -r pip-requirements.txt
molecule test --all
License
BSD
Author Information
Javier Ayala [email protected]
ansible-galaxy install javiergayala.users