robertdebock.users

Ansible Role Users

This role adds users and groups to your system.

GitHub GitLab Downloads Version
github gitlab downloads Version

Example Playbook

This example comes from molecule/default/converge.yml and is tested every time there’s a push, pull request, or release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: robertdebock.users
      users_groups:
        - name: robertdb
          gid: 1024
        - name: users
        - name: notgroup
          state: absent
        - name: systemgroup
          system: true

      users:
        - name: root
          cron_allow: true
          unauthorized_keys:
            - "ssh-rsa XYZYX54321"
        - name: robertdb
          comment: Robert de Bock
          uid: 1024
          group: robertdb
          groups:
            - users
          cron_allow: true
          sudo_options: "ALL=(ALL) NOPASSWD: ALL"
          authorized_keys:
            - "ssh-rsa ABC123"
          expires: -1
          password_validity_days: 9
        - name: notuser
          state: absent
        - name: systemuser
          system: true

To set up the machine, use molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: robertdebock.bootstrap
    - role: robertdebock.core_dependencies

  tasks:
    - name: Set authorized keys for root
      ansible.posix.authorized_key:
        user: root
        state: present
        key: "ssh-rsa XYZYX54321"

For more details, see this full explanation and example on how to use these roles.

Role Variables

Default variable values are set in defaults/main.yml:

---
# defaults file for users

# Directory for storing SSH keys for users
users_ssh_key_directory: ssh_keys

# Default shell if not specified
users_shell: /bin/bash

# Manage cron permissions via /etc/cron.allow
users_cron_allow: true

# Should home directories be created?
users_create_home: true

Requirements

State of Used Roles

Here are the roles used to prepare a system. You can prepare your system differently if you choose.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab
robertdebock.core_dependencies Build Status GitHub Build Status GitLab

Context

This role is part of other compatible roles. See the documentation of these roles for more information.

Overview of related roles: dependencies

Compatibility

This role has been tested on these container images:

Container Tags
Alpine all
Amazon Candidate
EL 9
Debian all
Fedora all
Ubuntu all

The minimum required version of Ansible is 2.12. Tests have been done on:

  • The previous version.
  • The current version.
  • The development version.

If you find any issues, please report them on GitHub.

License

Apache-2.0.

Author Information

robertdebock

Please consider sponsoring me.

Informazioni sul progetto

The purpose of this role is to add users and groups on your system.

Installa
ansible-galaxy install robertdebock.users
Licenza
apache-2.0
Download
216k
Proprietario
I know my way around (Linux) infrastructure, have a passion for automation, Docker, Ansible, Molecule and ci/cd.