2020-11-29 20:59:41 +00:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Ensure service directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ zigbee2mqtt_service_directory }}"
|
2021-02-04 20:49:05 +00:00
|
|
|
mode: 0750
|
2020-11-29 20:59:41 +00:00
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Create bind mount source directory
|
|
|
|
file:
|
|
|
|
path: "{{ item.name }}"
|
2021-02-04 20:49:05 +00:00
|
|
|
mode: 0750
|
2020-11-29 20:59:41 +00:00
|
|
|
state: directory
|
|
|
|
loop: "{{ zigbee2mqtt_volumes }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
when: item.bind | bool
|
|
|
|
|
|
|
|
- name: Deploy compose file to '{{ zigbee2mqtt_service_directory }}'
|
|
|
|
template:
|
|
|
|
src: "services/zigbee2mqtt_compose.yml.j2"
|
|
|
|
dest: "{{ zigbee2mqtt_service_directory }}/docker-compose.yml"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
validate: "docker-compose -f %s config -q"
|
|
|
|
|
|
|
|
- name: Deploy configuration file
|
|
|
|
template:
|
|
|
|
src: "zigbee2mqtt/data/configuration.yaml.j2"
|
|
|
|
dest: "{{ zigbee2mqtt_data_volume }}/configuration.yaml"
|
|
|
|
mode: 0600
|
|
|
|
notify: __zigbee2mqtt_restart
|
|
|
|
|
|
|
|
- name: Ensure device files exists
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
2021-02-04 20:49:05 +00:00
|
|
|
mode: 0640
|
2020-11-29 20:59:41 +00:00
|
|
|
state: touch
|
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
loop:
|
|
|
|
- "{{ zigbee2mqtt_data_volume }}/devices.yaml"
|
|
|
|
- "{{ zigbee2mqtt_data_volume }}/groups.yaml"
|
|
|
|
|
|
|
|
- name: Ensure service is up and running
|
|
|
|
docker_compose:
|
|
|
|
project_src: "{{ zigbee2mqtt_service_directory }}"
|
|
|
|
pull: yes
|
|
|
|
remove_orphans: yes
|
|
|
|
stopped: "{{ zigbee2mqtt_service_stopped }}"
|
|
|
|
state: present
|
|
|
|
become: True
|
|
|
|
become_user: root
|