mullholland.users

Ansible role users

Manages users and groups

GitHub Downloads Version
github downloads Version

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true
  vars:
    users_groups:
      - name: "mullholland"  # required
      # gid: "4711"  # optional
      # state: ""  # optional
      # system: ""  # optional [bool]
      - name: "full_opts"  # required
        gid: "4711"  # optional
        state: "present"  # optional
        system: "true"  # optional [bool]
      - name: "group_absent"  # required
        state: "absent"  # optional

    users:
      - name: "mullholland"
      # state: ""  # optional (defaults to present)
      # uid: ""  # optional
      # system: ""  # optional (bool)
      # `group` and `groups` must exist.
      # the user's primary group
      # group: "mullholland"
      # List of groups user will be added to.
      # When set to an empty string '', the user is
      # removed from all groups except the primary group.
      # groups: "users"
      # create_home: ""  # optional [bool] (defaults to true)
      # home: ""  # optional
      # shell: ""  # optional
      # comment: ""  # optional
      # Optionally set the user's password to this crypted value.
      # To create a disabled account on Linux systems, set this to '!' or '*'.
      # password: ""  # optional
      # update_password: ""  # optional [always/on_create] (defaults to on_create)
      # An expiry time for the user in epoch, it will be ignored on platforms that do not support this.
      # expires: ""  # optional
      # ssh_key: "ssh-rsa yyyxxccvvbb"  # optional
      # ssh_key_exclusive: ""  # optional [bool]
      # ssh_key_manage_dir: ""  # optional [bool]
      - name: "full_user"
        state: "present"
        uid: "4711"
        system: "true"
        group: "mullholland"
        groups: "users"
        create_home: "true"
        home: "/home/full_user"
        shell: "/bin/sh"
        comment: "managed by ansible"
        password: "!"
        # update_password: "always"  # not idempotent
        # expires: "1422403387"  # not idempotent
        ssh_key: |
          ssh-rsa yyyxxccvvbb
          ssh-rsa yyyxxccvvbbb
        ssh_key_exclusive: "true"
        ssh_key_manage_dir: "true"
      - name: "user_absent"
        state: "absent"

  roles:
    - role: "mullholland.users"

Role Variables

The default values for the variables are set in defaults/main.yml:

---
users_groups: []
# - name: "mullholland"  # required
#   gid: "4711"  # optional
#   state: ""  # optional
#   system: ""  # optional [bool]

users: []
# - name: "mullholland"
#   state: ""  # optional (defaults to present)
#   uid: ""  # optional
#   system: ""  # optional (bool)
#   `group` and `groups` must exist.
#   the user's primary group
#   group: "mullholland"
#   List of groups user will be added to.
#   When set to an empty string '', the user is
#   removed from all groups except the primary group.
#   groups: "users"
#   create_home: ""  # optional [bool] (defaults to true)
#   home: ""  # optional
#   shell: ""  # optional
#   comment: ""  # optional
#   Optionally set the user's password to this crypted value.
#   To create a disabled account on Linux systems, set this to '!' or '*'.
#   password: ""  # optional
#   update_password: ""  # optional [always/on_create] (defaults to on_create)
#   An expiry time for the user in epoch, it will be ignored on platforms that do not support this.
#   expires: ""  # optional
#   ssh_key: "ssh-rsa yyyxxccvvbb"  # optional
#   ssh_key_exclusive: ""  # optional [bool]
#   ssh_key_manage_dir: ""  # optional [bool]

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

Compatibility

This role has been tested on these container images:

container tags
EL all
Amazon Candidate
Fedora all
Ubuntu all
Debian all

The minimum version of Ansible required is 2.10, tests have been done to:

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

If you find issues, please register them in GitHub.

License

MIT.

Author Information

Mullholland

About

Manages users and groups

Install
ansible-galaxy install mullholland.users
GitHub repository
License
apache-2.0
Downloads
406