claranet.users

Ansible Role - Users

Maintainer
License
Release
Status
Ansible Version
Ansible Galaxy

⭐ Star us on GitHub — it encourages us a lot!

This role is designed to create user groups, add users, and configure users' dotfiles.

⚠️ Requirements

  • Ansible version must be 2.10 or higher.

⚡ Installation

Run the following command:

ansible-galaxy install claranet.users

⚙️ Role Variables

Users

You can modify the following user attributes: name, append, shell, createhome, home, password, uid, group, groups, update_password, state, remove, and comment.
More information here.

Variable Default Value Description
users {} Configure user groups, users, and enable bashrc, ssh/config, vimrc, and profile files.

Note: To manage group changes, we need to use chattr -a on the .bash_history file.

Packages

Variable Default Value Description
users_packages ["bash","bash-completion","vim","e2fsprogs"] List of essential packages for users.

Global Variables

Variable Default Value Description
users_umask 022 Default umask for files created by users.
users_lang POSIX Default language setting.
users_editor vim Default text editor is Vim.
users_ls_options --color=auto Default options for the ls command.

Dotfiles

Variable Default Value Description
users_default_bashrc defaults/main.yml Manages .bashrc file content.
users_default_vimrc defaults/main.yml Manages .vimrc file content.
users_default_profile defaults/main.yml Manages .profile file content.
users_bashrc_histcontrol ignoreboth Sets HISTCONTROL variable.
users_bashrc_histsize 5000 Sets HISTSIZE variable.
users_bashrc_histfilesize 20000 Sets HISTFILESIZE variable.
users_bashrc_histtimeformat %d-%m-%y %T Sets HISTTIMEFORMAT variable.
users_bashrc_template users/bashrc.j2 Configures ~/.bashrc.
users_ssh_config_template users/ssh_config.j2 Configures ~/.ssh/config.
users_vimrc_template users/vimrc.j2 Configures ~/.vimrc.
users_profile_template users/profile.j2 Configures ~/.profile.

Dotfiles (bashrc, ssh/config, vimrc, profile) are not enabled by default.
You must specify them for each user you want to configure (see example below).

🔄 Dependencies

Check tasks/install.yml.

✏️ Example Playbook

---
- hosts: all
  become: true
  become_user: root
  roles:
    - claranet.users
  vars:
    users:
      root:
        home: /root
        group: wheel
        password: "*"
        authorized_keys: ["ssh-rsa xxx"]
        bashrc:
          - 'export PS1=''\[\033[01;31m\]\u\[\033[00m\]@$(hostname -f) \[\033[01;34m\]\w \$\[\033[00m\] '''
        vimrc:
          - "color desert"
        profile: {}
        ssh_config:
          'mysrv*':
            identityFile: /home/user/.ssh/user
        ssh_keys:
          id_rsa:
            public: 'ssh-rsa '
            private: "{{ lookup('community.hashi_vault.hashi_vault', 'secret/ssh:private_key') }}"
        update_password: "on_create"         # default is always

🔒 Hardening

😍 Contributing

©️ License

Mozilla Public License Version 2.0

Informazioni sul progetto

Configure system's users

Installa
ansible-galaxy install claranet.users
Licenza
mpl-2.0
Download
28k
Proprietario
Open source projects from and contributed to by Claranet.