2021-03-14 16:46:46 +00:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Ensure service directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ homeassistant_service_directory }}"
|
|
|
|
mode: 0750
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Create bind mount source directory
|
|
|
|
file:
|
|
|
|
path: "{{ item.name }}"
|
|
|
|
mode: 0750
|
|
|
|
state: directory
|
|
|
|
loop: "{{ homeassistant_volumes }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
when: item.bind | bool
|
|
|
|
|
2021-04-17 12:11:48 +00:00
|
|
|
- name: Prepare directories
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2021-04-17 12:31:53 +00:00
|
|
|
mode: 0750
|
2021-04-17 12:11:48 +00:00
|
|
|
loop:
|
|
|
|
- "{{ homeassistant_plugin_dir }}"
|
|
|
|
|
2021-03-14 16:46:46 +00:00
|
|
|
- name: Deploy compose file to '{{ homeassistant_service_directory }}'
|
|
|
|
template:
|
|
|
|
src: "services/homeassistant_compose.yml.j2"
|
|
|
|
dest: "{{ homeassistant_service_directory }}/docker-compose.yml"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
validate: "docker-compose -f %s config -q"
|
|
|
|
|
|
|
|
- name: Patch /boot/cmdline
|
|
|
|
copy:
|
|
|
|
content: "{{ homeassistant_cmdline_content }}"
|
|
|
|
dest: /boot/cmdline.txt
|
2021-03-14 17:04:17 +00:00
|
|
|
mode: 0755
|
2021-03-14 16:46:46 +00:00
|
|
|
when: homeassistant_cmdline_override_enabled | bool
|
|
|
|
|
|
|
|
- name: Exclude serial devices from ModemManager
|
|
|
|
template:
|
|
|
|
src: "etc/udev/rules.d/99-mm-disable.rules.j2"
|
|
|
|
dest: "/etc/udev/rules.d/99-mm-disable.rules"
|
2021-03-14 17:04:17 +00:00
|
|
|
mode: 0640
|
2021-03-14 16:46:46 +00:00
|
|
|
when: homeassistant_exclude_modemmanager | bool
|
|
|
|
notify: __udev_reload
|
|
|
|
|
2021-04-17 12:11:48 +00:00
|
|
|
- name: Fetch plugins
|
|
|
|
get_url:
|
|
|
|
url: "{{ item.url }}"
|
|
|
|
dest: "{{ homeassistant_plugin_dir }}/{{ item.name }}"
|
|
|
|
mode: 0640
|
|
|
|
loop: "{{ homeassistant_plugins }}"
|
2021-04-17 12:31:53 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
2021-04-17 12:37:09 +00:00
|
|
|
notify: __homeassistant_restart
|
2021-04-17 12:11:48 +00:00
|
|
|
|
2021-03-14 16:46:46 +00:00
|
|
|
- name: Ensure service is up and running
|
|
|
|
docker_compose:
|
|
|
|
project_src: "{{ homeassistant_service_directory }}"
|
|
|
|
pull: yes
|
|
|
|
remove_orphans: yes
|
|
|
|
stopped: "{{ homeassistant_service_stopped }}"
|
|
|
|
state: present
|
|
|
|
become: True
|
|
|
|
become_user: root
|