|
|
@ -7,6 +7,12 @@
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|
- "{{ users }}"
|
|
|
|
- "{{ users }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure all groups are present or absent
|
|
|
|
|
|
|
|
group:
|
|
|
|
|
|
|
|
name: '{{ item.name | default(item) }}'
|
|
|
|
|
|
|
|
state: '{{ item.state | default("present") }}'
|
|
|
|
|
|
|
|
with_items: '{{ user_groups }}'
|
|
|
|
|
|
|
|
|
|
|
|
- name: get bash's path
|
|
|
|
- name: get bash's path
|
|
|
|
command: which bash
|
|
|
|
command: which bash
|
|
|
|
register: bash_path
|
|
|
|
register: bash_path
|
|
|
@ -14,10 +20,15 @@
|
|
|
|
changed_when: false
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
|
|
|
|
- name: create user
|
|
|
|
- name: create user
|
|
|
|
user: state=present
|
|
|
|
user:
|
|
|
|
name="{{ item.username if item.username is defined else item.name }}"
|
|
|
|
state: present
|
|
|
|
groups="{{ "sudo,adm" if item.sudo is defined and item.sudo }}" append=yes
|
|
|
|
name: "{{ item.username if item.username is defined else item.name }}"
|
|
|
|
shell={{ item.shell | default(bash_path.stdout) }}
|
|
|
|
groups:
|
|
|
|
|
|
|
|
- "{{ item.groups | default([]) | join(',')}}"
|
|
|
|
|
|
|
|
- "{{ 'sudo,adm' if item.sudo is defined and item.sudo }}"
|
|
|
|
|
|
|
|
append: true
|
|
|
|
|
|
|
|
shell: '{{ item.shell | default(bash_path.stdout) }}'
|
|
|
|
|
|
|
|
home: "{{ item.home | default('/home/' + (item.username | default(item.name))) }}"
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|
- "{{ users }}"
|
|
|
|
- "{{ users }}"
|
|
|
|
when: item.state != 'absent'
|
|
|
|
when: item.state != 'absent'
|
|
|
|