2019-10-05 21:42:04 +00:00
|
|
|
---
|
2019-11-26 00:58:52 +00:00
|
|
|
- name: create the users group
|
|
|
|
group:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
loop: "{{ user_default_groups }}"
|
|
|
|
|
2019-10-05 21:42:04 +00:00
|
|
|
- name: ensure groups
|
|
|
|
group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
gid: "{{ item.gid | default(omit) }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
system: false
|
|
|
|
with_items: "{{ users_groups }}"
|
|
|
|
when: users_groups is defined
|
|
|
|
|
|
|
|
- name: ensure users
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
uid: "{{ item.uid | default(omit) }}"
|
|
|
|
comment: "{{ item.comment | default(omit) }}"
|
|
|
|
create_home: "{{ item.create_home | default(true) }}"
|
|
|
|
group: "{{ item.group | default(omit) }}"
|
|
|
|
groups: "{{ item.groups | default(omit) }}"
|
|
|
|
home: "{{ item.home | default(omit) }}"
|
|
|
|
password: "{{ item.password | default(omit) }}"
|
2019-10-27 23:34:27 +00:00
|
|
|
shell: "{{ item.shell | default(user_default_shell) }}"
|
2019-10-05 21:42:04 +00:00
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
system: false
|
|
|
|
with_items: "{{ users_interactive }}"
|
|
|
|
when: users_interactive is defined
|
2019-10-27 23:34:27 +00:00
|
|
|
no_log: yes
|
2019-10-05 21:42:04 +00:00
|
|
|
|
|
|
|
- name: ensure system groups
|
|
|
|
group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
gid: "{{ item.gid | default(omit) }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
system: true
|
|
|
|
with_items: "{{ users_system_groups }}"
|
|
|
|
when: users_system_groups is defined
|
|
|
|
|
|
|
|
- name: ensure system users
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
uid: "{{ item.uid | default(omit) }}"
|
|
|
|
comment: "{{ item.comment | default(omit) }}"
|
|
|
|
create_home: "{{ item.create_home | default(false) }}"
|
|
|
|
group: "{{ item.group | default(omit) }}"
|
|
|
|
groups: "{{ item.groups | default(omit) }}"
|
|
|
|
home: "{{ item.home | default(omit) }}"
|
|
|
|
password: "{{ item.password | default(omit) }}"
|
|
|
|
shell: "{{ item.shell | default('/sbin/nologin') }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
system: true
|
|
|
|
with_items: "{{ users_system }}"
|
|
|
|
when: users_system is defined
|
2019-10-27 23:34:27 +00:00
|
|
|
no_log: yes
|
2019-10-05 21:42:04 +00:00
|
|
|
|
|
|
|
- name: ensure authorized keys
|
|
|
|
authorized_key:
|
|
|
|
user: "{{ item.0.name }}"
|
|
|
|
key: "{{ item.1 }}"
|
|
|
|
state: "{{ item.0.state | default('present') }}"
|
|
|
|
with_subelements:
|
|
|
|
- "{{ users_authorized_keys }}"
|
|
|
|
- keys
|
|
|
|
when:
|
|
|
|
- users_authorized_keys is defined
|