xoxys.homeassistant_docker/tasks/setup.yml

67 lines
1.9 KiB
YAML

---
- 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
- name: Prepare directories
file:
path: "{{ item }}"
state: directory
mode: 0640
loop:
- "{{ homeassistant_plugin_dir }}"
- 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
mode: 0755
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"
mode: 0640
when: homeassistant_exclude_modemmanager | bool
notify: __udev_reload
- name: Fetch plugins
get_url:
url: "{{ item.url }}"
dest: "{{ homeassistant_plugin_dir }}/{{ item.name }}"
mode: 0640
loop: "{{ homeassistant_plugins }}"
- 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