45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
---
|
|
- name: Ensure state is valid
|
|
ansible.builtin.fail:
|
|
msg: "Invalid state '{{ authelia_state }}'! Valid states are {{ authelia_states | join(', ') }}"
|
|
when: authelia_state not in authelia_states
|
|
|
|
- name: Ensure user {{ authelia_user }} is {{ authelia_state }}
|
|
ansible.builtin.user:
|
|
name: "{{ authelia_user }}"
|
|
state: "{{ authelia_state }}"
|
|
system: true
|
|
register: authelia_user_info
|
|
|
|
- name: Ensure host directories are created with correct permissions
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: "{{ (authelia_state == 'present') | ternary('directory', 'absent') }}"
|
|
owner: "{{ item.owner | default(authelia_user) }}"
|
|
group: "{{ item.group | default(authelia_user) }}"
|
|
mode: "{{ item.mode | default('0750') }}"
|
|
when: item.path | default(false, true) | bool
|
|
loop:
|
|
- path: "{{ authelia_base_dir }}"
|
|
mode: "0755"
|
|
- path: "{{ authelia_config_dir }}"
|
|
mode: "0750"
|
|
- path: "{{ authelia_data_dir }}"
|
|
mode: "0750"
|
|
- path: "{{ authelia_asset_dir }}"
|
|
mode: "0750"
|
|
|
|
- name: Ensure config file is generated
|
|
ansible.builtin.copy:
|
|
content: "{{ authelia_config | to_nice_yaml(indent=2, width=10000) }}"
|
|
dest: "{{ authelia_config_file }}"
|
|
owner: "{{ authelia_run_user }}"
|
|
group: "{{ authelia_run_group }}"
|
|
mode: "0640"
|
|
when: authelia_state == 'present'
|
|
notify: restart-authelia
|
|
|
|
- name: Deploy using {{ authelia_deployment_method }}
|
|
ansible.builtin.include_tasks:
|
|
file: "deploy-{{ authelia_deployment_method }}.yml"
|