forked from infra/ansible
homeassistant: Add installation procedures for homeassistant
This commit is contained in:
parent
552c9d71b3
commit
6bfff16a4b
@ -4,3 +4,8 @@
|
||||
ansible.builtin.service:
|
||||
name: postgresql
|
||||
state: restarted
|
||||
|
||||
- name: Restart homeassistant
|
||||
ansible.builtin.service:
|
||||
name: home-assistant
|
||||
state: restarted
|
||||
|
33
roles/homeassistant/tasks/installation.yml
Normal file
33
roles/homeassistant/tasks/installation.yml
Normal 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
|
@ -9,3 +9,5 @@
|
||||
loop:
|
||||
- preparation.yml
|
||||
- postgres.yml
|
||||
- systemd.yml
|
||||
- installation.yml
|
||||
|
17
roles/homeassistant/tasks/systemd.yml
Normal file
17
roles/homeassistant/tasks/systemd.yml
Normal 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
|
14
roles/homeassistant/templates/home-assistant.service.j2
Normal file
14
roles/homeassistant/templates/home-assistant.service.j2
Normal 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
|
Loading…
Reference in New Issue
Block a user