provision_management_user/tasks/create_user.yml

28 lines
1004 B
YAML
Raw Normal View History

2023-05-10 15:07:10 +00:00
---
2023-05-10 15:15:57 +00:00
# task/create_user file for provision_management_user
- name: "Create group {{ provision_management_user_group }}"
2023-05-10 15:07:10 +00:00
ansible.builtin.group:
2023-05-10 15:15:57 +00:00
name: "{{ provision_management_user_group }}"
2023-05-10 15:07:10 +00:00
state: present
2023-05-10 15:15:57 +00:00
system: "{{ provision_management_user_is_system }}"
2023-05-10 15:07:10 +00:00
2023-05-10 15:15:57 +00:00
- name: "Create user {{ provision_management_user_name }}"
2023-05-10 15:07:10 +00:00
ansible.builtin.user:
2023-05-10 15:15:57 +00:00
name: "{{ provision_management_user_name }}"
2023-05-15 16:22:48 +00:00
comment: "Management user"
2023-05-10 15:15:57 +00:00
password: "{{ provision_management_user_password }}"
group: "{{ provision_management_user_group }}"
home: "{{ provision_management_user_home }}"
shell: "{{ provision_management_user_shell }}"
system: "{{ provision_management_user_is_system }}"
2023-05-10 15:07:10 +00:00
create_home: true
- name: "Add user to sudoers"
ansible.builtin.copy:
2023-05-10 15:15:57 +00:00
dest: "/etc/sudoers.d/{{ provision_management_user_name }}"
2023-05-10 15:07:10 +00:00
owner: root
group: root
mode: 0640
2023-05-10 15:15:57 +00:00
content: "{{ provision_management_user_name }} ALL=(ALL) NOPASSWD: ALL"
when: provision_management_user_sudoer