1
0
Fork 0
ansible-collection-kit/roles/homeassistant/tasks/main.yml

104 lines
2.6 KiB
YAML
Raw Normal View History

2020-09-30 01:41:56 +02:00
---
- block:
2020-09-30 01:41:56 +02:00
- name: install homeassistant dependencies
apt:
name:
- autoconf
- build-essential
- libffi-dev
- libopenjp2-7
- libssl-dev
- libtiff5
- python3
- python3-dev
- python3-pip
- virtualenv
update_cache: true
cache_valid_time: 3600
2020-09-30 01:41:56 +02:00
- name: ensure homeassistant group exits
group:
name: homeassistant
system: true
2020-09-30 01:41:56 +02:00
- name: ensure homeassistant user exists and has restrictive settings
user:
name: homeassistant
groups: homeassistant
password: "*"
home: "{{ homeassistant_dir }}"
system: true
shell: /usr/sbin/nologin
2020-09-30 01:41:56 +02:00
- name: get available groups
getent:
database: group
2020-09-30 01:41:56 +02:00
- name: add homeassistant user to ssl-cert group
user:
name: homeassistant
groups: ssl-cert
append: true
become: true
2021-05-28 16:48:46 +02:00
when:
- homeassistant_add_to_ssl_cert_group
- ssl-cert in ansible_facts.getent_group
2020-09-30 01:41:56 +02:00
- name: add homeassistant user to dialout, gpio and i2c groups
user:
name: homeassistant
groups: dialout,gpio,i2c
append: true
when: is_a_raspberrypi
2020-09-30 01:41:56 +02:00
- name: install wheel and homeassistant inside a virtualenv
pip:
name:
- wheel
- homeassistant
virtualenv: "{{ homeassistant_dir }}"
2020-09-30 01:41:56 +02:00
- name: ensure homeassistant owns "{{ homeassistant_dir }}"
file:
path: "{{ homeassistant_dir }}"
state: directory
recurse: true
owner: homeassistant
group: homeassistant
2020-09-30 01:41:56 +02:00
- name: install homeassistant systemd unit file
template:
src: etc/systemd/system/homeassistant.service.j2
dest: /etc/systemd/system/homeassistant.service
notify:
- systemctl daemon-reload
2020-09-30 01:41:56 +02:00
- name: ensure homeassistant is enabled and started
systemd:
name: homeassistant
state: started
enabled: true
2020-09-30 01:41:56 +02:00
- name: Wait for port 8123
wait_for:
port: 8123
delay: 10
- name: add custom TLS settings in configuration.yaml
blockinfile:
2021-05-28 16:48:46 +02:00
path: "{{ homeassistant_dir }}/.homeassistant/configuration.yaml"
marker: "# {mark} ANSIBLE TLS SETTINGS"
block: |
http:
2021-05-28 16:48:46 +02:00
ssl_certificate: {{ homeassistant_ssl_certificate }}
ssl_key: {{ homeassistant_ssl_key }}
when:
- homeassistant_add_to_ssl_cert_group
- ssl-cert in ansible_facts.getent_group
- homeassistant_ssl_certificate and homeassistant_ssl_key
notify: systemctl restart homeassistant
become: "{{ homeassistant_become }}"
become_user: "{{ homeassistant_become_user }}"