Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ galaxy_info:
- name: Debian
versions:
- jessie
- bookworm
categories:
- system
- home-automation
17 changes: 8 additions & 9 deletions tasks/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
# Licensed under Apache 2.0. All rights reserved.
#
---
- name: install required python modules (pre-install)
pip:
name: "{{ item }}"
extra_args: "--upgrade"
executable: pip3
with_items:
- colorlog

- name: install defined version of Home Assistant
become: true
become_user: "{{ ha_user }}"
pip:
name: homeassistant
version: "{{ ha_version }}"
executable: pip3
virtualenv: "{{ ha_conf_dir }}/{{ ha_venv }}"
virtualenv_command: python3 -m venv
when: ha_version is defined

- name: install latest version of Home Assistant
become: true
become_user: "{{ ha_user }}"
pip:
name: homeassistant
extra_args: "--upgrade"
executable: pip3
virtualenv: "{{ ha_conf_dir }}/{{ ha_venv }}"
virtualenv_command: python3 -m venv
when: ha_version is undefined
1 change: 1 addition & 0 deletions tasks/motd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
---
- name: distribute the /etc/motd file
become: true
template:
src: motd.j2
dest: /etc/motd
Expand Down
38 changes: 26 additions & 12 deletions tasks/preparation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
---
- name: install commonly-named packages
become: true
package:
name: "{{ item }}"
state: present
Expand All @@ -30,34 +31,47 @@
when: ansible_distribution == "Fedora"

- name: install debian-specific packages
become: true
package:
name: "{{ item }}"
state: present
with_items:
- python3-dev
when: ansible_distribution == "Debian"

- name: install debian-required pip packages
pip:
name: "{{ item }}"
state: present
executable: pip3
with_items:
- appdirs
- packaging
- python3-venv
- acl
- ffmpeg
when: ansible_distribution == "Debian"

- name: create user
become: true
user:
name: "{{ ha_user }}"
comment: "Home Assistant"
system: yes
shell: "/sbin/nologin"
shell: "/bin/bash"

- name: create directory
become: true
file:
path: "{{ ha_conf_dir }}"
path: "{{ ha_conf_dir }}/.homeassistant"
state: directory
recurse: yes
mode: 02775
owner: "{{ ha_user }}"
group: "{{ ha_user }}"

- name: install debian-required pip packages
become: true
become_user: "{{ ha_user }}"
become_method: sudo
pip:
name:
- appdirs
- packaging
- colorlog
- wheel
state: present
virtualenv: "{{ ha_conf_dir }}/{{ ha_venv }}"
virtualenv_command: python3 -m venv
extra_args: "--upgrade"
when: ansible_distribution == "Debian"
6 changes: 4 additions & 2 deletions tasks/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
# Licensed under Apache 2.0. All rights reserved.
#
---
- shell: which hass
register: hass_command
#- shell: which hass
# register: hass_command

- name: install fedora systemd unit file
become: true
template:
src: home-assistant.service.j2
dest: "/etc/systemd/system/home-assistant.service"
Expand All @@ -17,6 +18,7 @@
mode: 0644

- name: start home assistant
become: true
systemd:
name: home-assistant
daemon_reload: yes
Expand Down
3 changes: 2 additions & 1 deletion templates/home-assistant.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ After=network.target
[Service]
Type=simple
User={{ ha_user }}
ExecStart={{ hass_command.stdout }} --config {{ ha_conf_dir }}
Restart=on-failure
ExecStart={{ ha_conf_dir }}/{{ ha_venv }}/bin/hass --config "{{ ha_conf_dir }}/.homeassistant"

[Install]
WantedBy=multi-user.target