2023-05-04 05:44:18 +00:00
|
|
|
- name: Reload systemd manager configuration
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: true
|
|
|
|
listen: compose_systemd
|
2023-10-10 03:47:49 +00:00
|
|
|
|
|
|
|
- name: Find which services had a docker-compose.yml updated
|
2023-10-22 17:48:20 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-10-10 03:47:49 +00:00
|
|
|
compose_restart_list: "{{ (compose_restart_list | default([])) + [item.item.name] }}"
|
|
|
|
loop: "{{ compose_update.results }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.name }}"
|
|
|
|
when: item.changed
|
|
|
|
listen: compose_restart
|
|
|
|
|
|
|
|
- name: Find which services had their .env updated
|
2023-10-22 17:48:20 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-10-10 03:47:49 +00:00
|
|
|
compose_restart_list: "{{ (compose_restart_list | default([])) + [item.item.name] }}"
|
|
|
|
loop: "{{ compose_env_update.results }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.name }}"
|
|
|
|
when: item.changed
|
|
|
|
listen: compose_restart
|
|
|
|
|
2023-10-22 15:33:05 +00:00
|
|
|
- name: Restart MariaDB
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: mariadb
|
|
|
|
state: restarted
|
|
|
|
when: not mariadb_restarted
|
|
|
|
listen: restart_mariadb # hijack handler for early restart
|
|
|
|
|
|
|
|
- name: Set MariaDB as restarted
|
2023-10-22 17:48:20 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-10-22 15:33:05 +00:00
|
|
|
mariadb_restarted: true
|
|
|
|
when: not mariadb_restarted
|
|
|
|
listen: restart_mariadb
|
|
|
|
|
2023-10-22 17:48:20 +00:00
|
|
|
- name: Restart compose services
|
2023-10-10 03:47:49 +00:00
|
|
|
ansible.builtin.systemd:
|
|
|
|
state: restarted
|
|
|
|
name: "{{ docker_compose_service }}@{{ item }}"
|
2023-10-22 17:48:20 +00:00
|
|
|
loop: "{{ compose_restart_list | default([]) | unique }}"
|
2023-10-10 03:47:49 +00:00
|
|
|
when: compose_restart_list is defined
|
|
|
|
listen: compose_restart
|
2023-10-22 15:33:05 +00:00
|
|
|
|
2023-10-22 17:48:20 +00:00
|
|
|
- name: Start compose services and enable on boot
|
2023-10-22 15:33:05 +00:00
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ docker_compose_service }}@{{ item.name }}"
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
loop: "{{ docker_compose_deploy }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ docker_compose_service }}@{{ item.name }}"
|
|
|
|
when: item.enabled is defined and item.enabled is true
|
|
|
|
listen: compose_enable
|