infra/roles/hass-zigbee2mqtt/tasks/hass-zigbee2mqtt.yml

81 lines
2.1 KiB
YAML

---
- name: remove hass-deconz container
docker_container:
name: hass-deconz
state: absent
when:
- hass_zigbee == "zigbee2mqtt"
- hass_deconz|default(false) == false
tags:
- hass-zigbee-container
- hass-zigbee2mqtt-container
- hass-container
- docker-containers
- name: create dir structure
file:
path: "{{ systemuserlist.hass.home }}/{{ item.name }}"
state: directory
mode: "{{ item.mode | default('0755') }}"
owner: hass
group: hass
tags:
- hass-dirs
- hass-zigbee-dirs
- hass-zigbee2mqtt-dirs
loop_control:
label: "{{ item.name }}"
with_items:
- name: zigbee2mqtt
- name: zigbee2mqtt/data
- name: zigbee2mqtt/log
- name: template zigbee2mqtt configuration.yaml
template:
src: configuration.yaml.j2
dest: "{{ systemuserlist.hass.home }}/zigbee2mqtt/data/configuration.yaml"
owner: hass
group: hass
mode: 0644
notify: restart hass-zigbee2mqtt container
tags:
- hass-zigbee-config
- hass-zigbee2mqtt-config
- name: start hass-zigbee container
docker_container:
name: hass-zigbee2mqtt
image: koenkk/zigbee2mqtt:latest
detach: true
pull: true
auto_remove: false
restart_policy: "unless-stopped"
state: "{{ hass_container_state | default('stopped') }}"
container_default_behavior: compatibility
user: "{{ systemuserlist.hass.uid }}:dialout"
networks_cli_compatible: false
network_mode: bridgewithdns
networks:
- name: bridgewithdns
ipv4_address: "{{ bridgewithdns.hass_zigbee2mqtt }}"
#devices:
# - "/dev/zigbee0:/dev/zigbee:rwm"
env:
TZ: "Europe/Berlin"
mounts:
- type: bind
source: "{{ systemuserlist.hass.home }}/zigbee2mqtt/data"
target: /app/data
- type: bind
source: "{{ systemuserlist.hass.home }}/zigbee2mqtt/log"
target: /app/data/log
register: hass_zigbee2mqtt_container
when:
- hass_zigbee == "zigbee2mqtt" or hass_zigbee2mqtt|default(false) == true
tags:
- hass-zigbee-container
- hass-zigbee2mqtt-container
- hass-container
- docker-containers