ansible-infra/playbooks/roles/zigbee2mqtt/tasks/main.yml

63 lines
1.8 KiB
YAML

- name: Ensure acl is installed
ansible.builtin.apt:
name: acl
- name: Ensure git is installed
ansible.builtin.apt:
name: git
- name: Ensure zigbee2mqtt user exists
ansible.builtin.user:
name: zigbee2mqtt
groups:
- zigbee2mqtt
- dialout
group: zigbee2mqtt
- name: Ensure installation dirrectory exists
ansible.builtin.file:
dest: /opt/zigbee2mqtt
state: directory
mode: 0755
owner: zigbee2mqtt
group: zigbee2mqtt
- name: Ensure zigbee2mqtt repository is cloned
become_user: zigbee2mqtt
ansible.builtin.git:
repo: https://github.com/Koenkk/zigbee2mqtt.git
depth: 1
dest: /opt/zigbee2mqtt
version: "{{ zigbee2mqtt__version }}"
notify: Restart zigbee2mqtt
- name: Ensure npm dependencies are installed
become_user: zigbee2mqtt
community.general.npm:
path: /opt/zigbee2mqtt
ci: true
changed_when: false # installs packages according to package-lock.json, but always reports a change
- name: Ensure custom zigbee2mqtt data directory exists
ansible.builtin.file:
dest: /home/zigbee2mqtt/zigbee2mqtt_data
state: directory
mode: 0755
owner: zigbee2mqtt
group: zigbee2mqtt
- name: Ensure configuration file is deployed
ansible.builtin.copy:
content: "{{ zigbee2mqtt__config }}"
dest: /home/zigbee2mqtt/zigbee2mqtt_data/configuration.yaml
mode: 0640
owner: zigbee2mqtt
group: zigbee2mqtt
notify: Restart zigbee2mqtt
- name: Ensure zigbee2mqtt service file is deployed
ansible.builtin.copy:
src: zigbee2mqtt.service
dest: /etc/systemd/system/zigbee2mqtt.service
mode: 0644
owner: root
group: root
notify: Reload systemd-daemon and restart zigbee2mqtt
- name: Ensure zigbee2mqtt is enabled and started
ansible.builtin.systemd:
service: zigbee2mqtt
enabled: true
state: started