| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- ---
- - name: Ensure Linux group users are configured with UIDs, passwords, groups and keys
- hosts: all
- gather_facts: true
- become: True
- tasks:
- - name: "userinfofile"
- include_vars:
- dir: "include/linux_group_users"
- ignore_unknown_extensions: True
- extensions: [ 'userinfo.yaml', 'yaml' ]
- - debug:
- msg: "{{ username }}"
- - name: "Add/modify a user with a specific uid, passwd hash & public key(s)"
- user:
- name: "{{ username }}"
- comment: "{{ fullname }}"
- shell: /bin/bash
- uid: "{{ uid }}"
- password: "{{ shadowhash }}"
- state: present
- - name: "Append the wheel group"
- user:
- name: "{{ username }}"
- groups: wheel
- append: yes
- - name: "Append the sudonopsswd group"
- user:
- name: "{{ username }}"
- groups: sudonopsswd
- append: yes
- - name: "Append/modify the *sudo* group to above user if it exists on the system"
- user:
- name: "{{ username }}"
- with_items:
- - { groups: 'sudo' }
- - { append: 'yes' }
- ignore_errors: true
- - name: "Append/modify the *wheel* group to above user if it exists on the system"
- user:
- name: "{{ username }}"
- with_items:
- - { groups: 'wheel' }
- - { append: 'yes' }
- ignore_errors: true
- - name: "Append/modify the *sudonopsswd* group to above user if it exists on the system"
- user:
- name: "{{ username }}"
- with_items:
- - { groups: 'sudonopsswd' }
- - { append: 'yes' }
- ignore_errors: false
- - name: "Set auth keys for user"
- authorized_key:
- user: "{{ username }}"
- state: present
- key: '{{ item }}'
- with_file:
- - "{{ pubkeysfile }}"
- - debug:
- msg:
- - " PUBKEYSFILE was read in as {{ pubkeysfile }} "
|