homeassistant/tasks/main.yml
2026-10-12 23:44:19 +02:00

69 lines
1.8 KiB
YAML

---
- name: "set local variables from overrides and defaults"
set_fact:
homeassistant: "{{ (homeassistant_defaults | combine(homeassistant_override, recursive=True)) if homeassistant_override else homeassistant_defaults }}"
- name: ensure that path exists
file:
path: "{{ path }}/config/homeassistant"
state: directory
- name: ensure that mosquitto config path exists
file:
path: "{{ path }}/config/mosquitto"
state: directory
- name: ensure that mosquitto data path exists
file:
path: "{{ item }}"
state: directory
owner: "1883"
group: "1883"
loop:
- "{{ path }}/data/mosquitto"
- "{{ path }}/data/mosquitto/log"
- name: ensure that zigbee2mqtt data path exists
file:
path: "{{ path }}/data/zigbee2mqtt"
state: directory
- name: template docker-compose
template:
src: compose.yml.j2
dest: "{{ path }}/compose.yml"
- name: template .env
template:
src: .env.j2
dest: "{{ path }}/.env"
- name: template mosquitto config
template:
src: mosquitto.conf.j2
dest: "{{ path }}/config/mosquitto/mosquitto.conf"
mode: "0644"
- name: template zigbee2mqtt config
ansible.builtin.blockinfile:
path: "{{ path }}/data/zigbee2mqtt/configuration.yaml"
create: true
mode: "0644"
marker: "# Ansible {mark}"
marker_begin: start
marker_end: end
block: "{{ lookup('template', 'zigbee2mqtt/configuration.yaml.j2') }}"
- name: Do configuration
include_tasks: ensure_configuration.yml
- name: ensure container is running
community.docker.docker_compose_v2:
project_src: "{{ path }}"
project_name: "{{ role_name }}"
state: "present"
pull: "always"
wait: true
services: ["mariadb", "mosquitto", "homeassistant", "zigbee2mqtt"]
register: _compose_result