2022-04-10 09:05:40 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure user {{ authelia_user }} exists
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.user:
|
2022-04-10 09:05:40 +00:00
|
|
|
name: "{{ authelia_user }}"
|
|
|
|
state: present
|
|
|
|
system: true
|
|
|
|
register: authelia_user_info
|
|
|
|
|
|
|
|
- name: Ensure host directories are created with correct permissions
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.file:
|
2022-04-10 09:05:40 +00:00
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ item.owner | default(authelia_user) }}"
|
|
|
|
group: "{{ item.group | default(authelia_user) }}"
|
|
|
|
mode: "{{ item.mode | default('0750') }}"
|
2022-08-26 06:48:36 +00:00
|
|
|
when: item.path | default(false, true) | bool
|
2022-04-10 09:05:40 +00:00
|
|
|
loop:
|
|
|
|
- path: "{{ authelia_base_dir }}"
|
|
|
|
mode: "0755"
|
|
|
|
- path: "{{ authelia_config_dir }}"
|
|
|
|
mode: "0750"
|
|
|
|
- path: "{{ authelia_data_dir }}"
|
|
|
|
mode: "0750"
|
2022-08-26 06:48:36 +00:00
|
|
|
- path: "{{ authelia_asset_dir }}"
|
|
|
|
mode: "0750"
|
2022-04-10 09:05:40 +00:00
|
|
|
|
|
|
|
- name: Ensure config file is generated
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.copy:
|
2022-04-10 09:05:40 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
- name: Ensure sqlite database file exists before mounting it
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.file:
|
2022-04-10 09:05:40 +00:00
|
|
|
path: "{{ authelia_sqlite_storage_file }}"
|
|
|
|
state: touch
|
|
|
|
owner: "{{ authelia_run_user }}"
|
|
|
|
group: "{{ authelia_run_group }}"
|
|
|
|
mode: "0640"
|
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
when: authelia_config_storage_local_path | default(false, true)
|
|
|
|
|
|
|
|
- name: Ensure user database exists before mounting it
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.file:
|
2022-04-10 09:05:40 +00:00
|
|
|
path: "{{ authelia_user_storage_file }}"
|
|
|
|
state: touch
|
|
|
|
owner: "{{ authelia_run_user }}"
|
|
|
|
group: "{{ authelia_run_group }}"
|
|
|
|
mode: "0640"
|
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
when: authelia_config_authentication_backend_file_path | default(false, true)
|
|
|
|
|
|
|
|
- name: Ensure notification reports file exists before mounting it
|
2024-10-03 20:18:34 +00:00
|
|
|
ansible.builtin.file:
|
2022-04-10 09:05:40 +00:00
|
|
|
path: "{{ authelia_notification_storage_file }}"
|
|
|
|
state: touch
|
|
|
|
owner: "{{ authelia_run_user }}"
|
|
|
|
group: "{{ authelia_run_group }}"
|
|
|
|
mode: "0640"
|
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
when: authelia_config_notifier_filesystem_filename | default(false, true)
|
|
|
|
|
|
|
|
- name: Ensure authelia container image is present
|
|
|
|
community.docker.docker_image:
|
|
|
|
name: "{{ authelia_container_image_ref }}"
|
|
|
|
state: present
|
|
|
|
source: pull
|
|
|
|
force_source: "{{ authelia_container_image_force_pull }}"
|
|
|
|
register: authelia_container_image_info
|
|
|
|
|
|
|
|
- name: Ensure authelia container is running
|
2024-10-03 20:18:34 +00:00
|
|
|
community.docker.docker_container:
|
2022-04-10 09:05:40 +00:00
|
|
|
name: "{{ authelia_container_name }}"
|
|
|
|
image: "{{ authelia_container_image_ref }}"
|
|
|
|
env: "{{ authelia_container_env }}"
|
|
|
|
user: "{{ authelia_run_user }}:{{ authelia_run_group }}"
|
|
|
|
ports: "{{ authelia_container_ports | default(omit, true) }}"
|
|
|
|
labels: "{{ authelia_container_labels }}"
|
|
|
|
volumes: "{{ authelia_container_volumes }}"
|
|
|
|
networks: "{{ authelia_container_networks | default(omit, true) }}"
|
2024-10-03 15:06:49 +00:00
|
|
|
etc_hosts: "{{ authelia_container_etc_hosts | default(omit, true) }}"
|
2022-04-10 09:05:40 +00:00
|
|
|
purge_networks: "{{ authelia_container_purge_networks | default(omit, true)}}"
|
|
|
|
restart_policy: "{{ authelia_container_restart_policy }}"
|
2024-10-03 20:19:16 +00:00
|
|
|
recreate: "{{ authelia_container_recreate | default(omit, true) }}"
|
2022-04-10 09:05:40 +00:00
|
|
|
state: "{{ authelia_container_state }}"
|
|
|
|
register: authelia_container_info
|