From bd1f506d8b90b37da2e420028ce8da4e6879d517 Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Mon, 24 Jan 2022 22:18:15 +0100 Subject: [PATCH] initial commit --- files/homeassistant.service | 12 ++++++++++++ handlers/main.yml | 4 ++++ meta/main.yml | 1 + tasks/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 files/homeassistant.service create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml 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