commit bd1f506d8b90b37da2e420028ce8da4e6879d517 Author: Patrick Neff Date: Mon Jan 24 22:18:15 2022 +0100 initial commit diff --git a/files/homeassistant.service b/files/homeassistant.service new file mode 100644 index 0000000..d8b236c --- /dev/null +++ b/files/homeassistant.service @@ -0,0 +1,12 @@ +[Unit] +Description=Home Assistant +After=network-online.target + +[Service] +Type=simple +User=homeassistant +WorkingDirectory=/home/homeassistant/.homeassistant +ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant" + +[Install] +WantedBy=multi-user.target diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..fe469ce --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart homeassistant + ansible.builtin.service: + name: homeassistant + state: restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..32cf5dd --- /dev/null +++ b/meta/main.yml @@ -0,0 +1 @@ +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..07ac41f --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,36 @@ +- name: Install dependencies. + ansible.builtin.package: + name: + - python3 + - python3-dev + - python3-venv + - python3-pip + - libffi-dev + - libssl-dev + - libjpeg-dev + - zlib1g-dev + - autoconf + - build-essential + - libopenjp2-7 + - libtiff5 + - libturbojpeg0 + - tzdata + +- name: Install home-assistant + ansible.builtin.pip: + name: homeassistant + virtualenv: /srv/homeassistant + +- name: Create home-assistant systemd service. + ansible.builtin.copy: + src: homeassistant.service + dest: /etc/systemd/system/homeassistant.service + owner: root + group: root + mode: 0644 + +- name: Enable homeassistant service. + ansible.builtin.service: + name: homeassistant + state: started + enabled: yes