homeassistant: Add installation procedures for homeassistant

This commit is contained in:
Thomas Basler 2024-10-02 23:07:09 +02:00
parent 552c9d71b3
commit 6bfff16a4b
5 changed files with 71 additions and 0 deletions

View File

@ -4,3 +4,8 @@
ansible.builtin.service:
name: postgresql
state: restarted
- name: Restart homeassistant
ansible.builtin.service:
name: home-assistant
state: restarted

View File

@ -0,0 +1,33 @@
---
- name: Install defined version of Home Assistant
ansible.builtin.pip:
name:
- wheel
- psycopg2
- packaging
- uv
- netifaces
- homeassistant=={{ ha_version }}
virtualenv: '{{ ha_venv_dir }}'
virtualenv_command: 'python{{ ha_python_version }} -m venv'
when: ha_version is defined
become: true
become_user: "{{ ha_user }}"
notify: Restart homeassistant
- name: Install latest version of Home Assistant
ansible.builtin.pip:
name:
- wheel
- psycopg2
- packaging
- uv
- homeassistant
extra_args: "--upgrade"
virtualenv: "{{ ha_venv_dir }}"
virtualenv_command: 'python{{ ha_python_version }} -m venv'
when: ha_version is undefined
become: true
become_user: "{{ ha_user }}"
notify: Restart homeassistant

View File

@ -9,3 +9,5 @@
loop:
- preparation.yml
- postgres.yml
- systemd.yml
- installation.yml

View File

@ -0,0 +1,17 @@
---
- name: Install systemd unit file
ansible.builtin.template:
src: home-assistant.service.j2
dest: "/etc/systemd/system/home-assistant.service"
owner: root
group: root
mode: "0644"
notify: Restart homeassistant
- name: Enable home assistant service
ansible.builtin.systemd:
name: home-assistant
daemon_reload: true
enabled: true
notify: Restart homeassistant

View File

@ -0,0 +1,14 @@
[Unit]
Description=Home Assistant
After=network.target postgresql.service
[Service]
Type=simple
User={{ ha_user }}
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ ha_venv_dir }}/bin"
ExecStart={{ ha_venv_dir }}/bin/hass --config {{ ha_conf_dir }}
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target