xoxys.zigbee2mqtt/tasks/main.yml
Robert Kaussow 68bffd8e2a
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
fix: fix ansible lint
2024-10-16 22:32:58 +02:00

59 lines
1.8 KiB
YAML

---
- name: Create container volumes
community.docker.docker_volume:
name: "{{ item.name }}"
driver_options: "{{ item.options | default(omit) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ zigbee2mqtt_volumes }}"
loop_control:
label: "{{ item.name }}"
when: item.type | default("volume") | lower == "volume"
register: __zigbee2mqtt_volumes_raw
- name: Register container volumes map
ansible.builtin.set_fact:
__zigbee2mqtt_volumes_map: "{{ __zigbee2mqtt_volumes_raw.results | json_query('[].volume') | items2dict(key_name='Name', value_name='Mountpoint') }}"
- name: Deploy env file
ansible.builtin.template:
src: etc/sysconfig/zigbee2mqtt.j2
dest: "/etc/sysconfig/zigbee2mqtt"
owner: root
group: root
mode: "0600"
notify: __zigbee2mqtt_restart
- name: Create container specs
ansible.builtin.template:
src: etc/systemd/system/zigbee2mqtt.service.j2
dest: "/etc/systemd/system/zigbee2mqtt.service"
owner: root
group: root
mode: "0640"
notify: __zigbee2mqtt_restart
- name: Deploy configuration file
ansible.builtin.template:
src: "zigbee2mqtt/configuration.yaml.j2"
dest: "{{ __zigbee2mqtt_volumes_map[zigbee2mqtt_data_volume] }}/configuration.yaml"
mode: "0600"
notify: __zigbee2mqtt_restart
- name: Ensure device files exists
ansible.builtin.file:
path: "{{ item }}"
mode: "0640"
state: touch
access_time: preserve
modification_time: preserve
loop:
- "{{ __zigbee2mqtt_volumes_map[zigbee2mqtt_data_volume] }}/devices.yaml"
- "{{ __zigbee2mqtt_volumes_map[zigbee2mqtt_data_volume] }}/groups.yaml"
- name: Ensure service state
ansible.builtin.service:
name: "zigbee2mqtt.service"
state: "{{ zigbee2mqtt_service_started | ternary('started', 'stopped', 'started') }}"
daemon_reload: True
enabled: True