36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
|
---
|
||
|
- name: Ensure element user '{{ element_user }}' is {{ element_state }}
|
||
|
ansible.builtin.user:
|
||
|
name: "{{ element_user }}"
|
||
|
system: "{{ element_user_system | default(true, true) }}"
|
||
|
create_home: "{{ element_user_create_home | default(false, true) }}"
|
||
|
state: "{{ element_state }}"
|
||
|
register: element_user_info
|
||
|
|
||
|
- name: Ensure host paths are {{ element_state }}
|
||
|
ansible.builtin.file:
|
||
|
name: "{{ path.name }}"
|
||
|
state: "{{ (element_state == 'present') | ternary('directory', 'absent') }}"
|
||
|
owner: "{{ path.owner | default(element_host_uid) }}"
|
||
|
group: "{{ path.group | default(element_host_gid) }}"
|
||
|
mode: "{{ path.mode | default('0750') }}"
|
||
|
loop_control:
|
||
|
loop_var: path
|
||
|
label: "{{ path.name }}"
|
||
|
loop:
|
||
|
- name: "{{ element_base_path }}"
|
||
|
mode: '0755'
|
||
|
- name: "{{ element_config_path }}"
|
||
|
mode: '0755'
|
||
|
- name: "{{ element_source_path }}"
|
||
|
mode: '0750'
|
||
|
|
||
|
- name: Ensure config file is {{ element_state }}
|
||
|
ansible.builtin.copy:
|
||
|
content: "{{ element_config | to_nice_json }}"
|
||
|
dest: "{{ element_config_file }}"
|
||
|
owner: "{{ element_host_uid }}"
|
||
|
group: "{{ element_host_gid }}"
|
||
|
mode: "{{ element_config_file_mode | default('0664') }}"
|
||
|
when: element_state == 'present'
|