46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
|
- name: Create home-assistant directory
|
||
|
file:
|
||
|
path: /opt/home-assistant
|
||
|
state: directory
|
||
|
owner: "{{ docker_user.name }}"
|
||
|
mode: "{{ docker_compose_directory_mask }}"
|
||
|
become: true
|
||
|
|
||
|
- name: Create config directory
|
||
|
file:
|
||
|
path: /opt/home-assistant/config
|
||
|
state: directory
|
||
|
mode: "{{ docker_compose_directory_mask }}"
|
||
|
become: true
|
||
|
|
||
|
- name: Install home-assistant compose file
|
||
|
template:
|
||
|
src: files/docker-compose.yml
|
||
|
dest: /opt/home-assistant/docker-compose.yml
|
||
|
mode: "{{ docker_compose_file_mask }}"
|
||
|
owner: "{{ docker_user.name }}"
|
||
|
validate: /usr/bin/docker-compose -f %s config
|
||
|
register: compose_file
|
||
|
become: true
|
||
|
|
||
|
- name: Install config
|
||
|
template:
|
||
|
src: files/configuration.yml
|
||
|
dest: /opt/home-assistant/config/configuration.yaml
|
||
|
mode: "{{ docker_compose_file_mask }}"
|
||
|
owner: "{{ docker_user.name }}"
|
||
|
register: config_file
|
||
|
become: true
|
||
|
|
||
|
- name: Cycle home-assistant container
|
||
|
docker_compose:
|
||
|
project_src: /opt/home-assistant
|
||
|
pull: true
|
||
|
remove_orphans: true
|
||
|
remove_volumes: true
|
||
|
state: "{{ item }}"
|
||
|
when: compose_file.changed or config_file.changed
|
||
|
loop:
|
||
|
- absent
|
||
|
- present
|