[WIP] Perform installation of HomeAssistant host #71

Draft
noby wants to merge 13 commits from noby/ansible:homeassistant into master
5 changed files with 71 additions and 0 deletions
Showing only changes of commit 6bfff16a4b - Show all commits

View File

@ -4,3 +4,8 @@
ansible.builtin.service: ansible.builtin.service:
name: postgresql name: postgresql
state: restarted 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: loop:
- preparation.yml - preparation.yml
- postgres.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