2022-02-28 22:43:30 +03:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Users | Install sudo package
|
|
|
|
package:
|
|
|
|
name: sudo
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Users | Deploy /etc/sudoers
|
|
|
|
template:
|
|
|
|
src: sudoers.j2
|
|
|
|
dest: /etc/sudoers
|
|
|
|
mode: 0440
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- name: Users | Create groups
|
|
|
|
group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
state: present
|
2022-03-01 00:12:28 +03:00
|
|
|
with_items: "{{ managed_groups }}"
|
2022-02-28 22:43:30 +03:00
|
|
|
|
|
|
|
- name: Users | Create users
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
state: "{{ item.state | default(omit) }}"
|
|
|
|
home: "{{ item.home | default(omit) }}"
|
|
|
|
move_home: yes
|
|
|
|
shell: "{{ item.shell | default(omit) }}"
|
|
|
|
password: "{{ item.password | default(omit) }}"
|
|
|
|
groups: "{{ item.groups | default(omit) }}"
|
|
|
|
append: no
|
|
|
|
system: "{{ item.system | default(omit) }}"
|
2022-03-01 00:12:28 +03:00
|
|
|
with_items: "{{ managed_users }}"
|
2022-02-28 22:43:30 +03:00
|
|
|
|
|
|
|
- name: Users | Deploy ssh public keys
|
|
|
|
authorized_key:
|
|
|
|
exclusive: yes
|
|
|
|
user: "{{ item.name }}"
|
|
|
|
key: "{{ lookup(item.lookup, item.keys_source) }}"
|
2022-03-01 00:12:28 +03:00
|
|
|
with_items: "{{ managed_users }}"
|
2022-02-28 22:43:30 +03:00
|
|
|
when:
|
|
|
|
- item.lookup is defined
|
|
|
|
- item.keys_source is defined
|