xoxys.homeassistant_docker/tasks/install.yml

70 lines
2.0 KiB
YAML

---
- name: Prepare base folders
file:
path: "{{ item }}"
state: directory
owner: "{{ homeassistant_user }}"
group: "{{ homeassistant_user }}"
mode: 0750
loop:
- "{{ homeassistant_base_dir }}"
- "{{ homeassistant_conf_dir }}"
become: True
become_user: root
- block:
- name: Upgrade python dependencies
pip:
name: "{{ item }}"
virtualenv: "{{ homeassistant_base_dir }}/venv"
virtualenv_command: /usr/bin/python3 -m venv
extra_args: --upgrade
loop:
- pip
- setuptools
- wheel
- name: Install with pip and virtualenv
pip:
name: homeassistant
version: "{{ homeassistant_version }}"
virtualenv: "{{ homeassistant_base_dir }}/venv"
virtualenv_command: /usr/bin/python3 -m venv
notify: __homeassistant_restart
become: True
become_user: "{{ homeassistant_user }}"
- block:
- name: Patch /boot/cmdline
copy:
content: "{{ homeassistant_cmdline_content }}"
dest: /boot/cmdline.txt
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"
when: homeassistant_exclude_modemmanager | bool
notify: __udev_reload
- name: Copy systemd unit file
template:
src: "etc/systemd/system/homeassistant.service.j2"
dest: "/etc/systemd/system/homeassistant.service"
notify: __homeassistant_restart
- name: Open ports in iptables
iptables_raw:
name: "{{ item.name }}"
rules: "{{ item.rules }}"
state: "{{ item.state }}"
weight: "{{ item.weight | default(omit) }}"
table: "{{ item.table | default(omit) }}"
loop: "{{ homeassistant_open_ports }}"
loop_control:
label: "{{ item.name }}"
when: homeassistant_iptables_enabled | bool
become: True
become_user: root