--- - name: Check for valid state ansible.builtin.fail: msg: >-2 Unsupported state '{{ authelia_state }}'. Supported states are {{ authelia_states | join(', ') }}. when: authelia_state not in authelia_states - name: Check for valid authelia deployment method ansible.builtin.fail: msg: >-2 Unsupported deployment method '{{ authelia_deployment_method }}'. Supported states are {{ authelia_deployment_methods | join(', ') }}. when: authelia_deployment_method not in authelia_deployment_methods - name: Ensure user {{ authelia_user }} is {{ authelia_state }} ansible.builtin.user: name: "{{ authelia_user }}" state: "{{ authelia_state }}" system: true create_home: false register: authelia_user_info - name: Ensure host directories are {{ authelia_state }} 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 {{ authelia_state }} 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" notify: restart-authelia when: authelia_state == 'present' - name: Deploy authelia using {{ authelia_deployment_method }} ansible.builtin.include_tasks: file: "deploy-{{ authelia_deployment_method }}.yml"