ansible_user_management

Role Name

ansible_user_management

This Ansible role facilitates user management tasks such as creating, modifying, and removing users on a Unix/Linux system.


Requirements

This role does not have any pre-requisites other than a standard Ansible setup. The target system should have the necessary privileges to create, modify, or delete user accounts.


Role Variables

The following variables can be set to manage users:

Defined in defaults/main.yml:

  • users_to_create: A list of users you wish to create.
  • users_to_modify: A list of users you wish to modify.
  • users_to_remove: A list of usernames you wish to remove.

Defined in vars/main.yml:

You can define user-specific details like their name, hashed password, and preferred shell.

# vars/main.yml
users_to_create:
  - name: alice
    password: "$6$SomeHashedValue..." # hashed_alice_password
    shell: "/bin/bash"
  - name: bob
    password: "$6$SomeHashedValue..." # hashed_bob_password
    shell: "/bin/zsh"
  - name: charlie
    password: "$6$SomeHashedValue..." # hashed_charlie_password
    shell: "/bin/bash"

users_to_modify:
  - name: alice
    password: "$6$SomeNeWHashedValue..." # new_hashed_alice_password
    shell: "/bin/zsh"

users_to_remove:
  - charlie

Dependencies

As of now, this role doesn't have any dependencies on other Ansible Galaxy roles.


Example Playbook

Using the role in a playbook:

# site.yml
- hosts: localhost # or <hosts> (Remote Server)
  become: yes
  vars_files:
    - ~/vars.yml
  roles:
    - somaz94.ansible_user_management
# vars.yml
users_to_create:
  - name: alice
    password: "$6$SomeHashedValue..." # hashed_alice_password
    shell: "/bin/bash"
  - name: bob
    password: "$6$SomeHashedValue..." # hashed_bob_password
    shell: "/bin/zsh"
  - name: charlie
    password: "$6$SomeHashedValue..." # hashed_charlie_password
    shell: "/bin/bash"

users_to_modify:
  - name: bob
    password: "$6$SomeNeWHashedValue..." # new_hashed_alice_password
    shell: "/bin/bash"

users_to_remove:
  - charlie

Running the Playbook

Execute the playbook with the following command:

ansible-playbook site.yml

License

This project is licensed under the MIT License - see the LICENSE file for details.


Author Information

About

Ansible role to User Management(Create, Delete, Modify)

Install
ansible-galaxy install somaz94/ansible_user_management
GitHub repository
License
mit
Downloads
14
Owner