Robert Kaussow
f14108b4dc
All checks were successful
continuous-integration/drone/push Build is passing
77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
---
|
|
- name: Create directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ zigbee2mqtt_user }}"
|
|
group: "{{ zigbee2mqtt_group }}"
|
|
mode: 0750
|
|
loop:
|
|
- "{{ zigbee2mqtt_base_dir }}"
|
|
- "{{ zigbee2mqtt_base_dir }}/data"
|
|
- "{{ zigbee2mqtt_log_dir }}"
|
|
become: True
|
|
become_user: root
|
|
|
|
- block:
|
|
- name: Download release 'v{{ zigbee2mqtt_version }}'
|
|
unarchive:
|
|
src: "https://github.com/Koenkk/zigbee2mqtt/archive/{{ zigbee2mqtt_version }}.tar.gz"
|
|
dest: "{{ zigbee2mqtt_base_dir }}"
|
|
remote_src: yes
|
|
exclude: "{{ __zigbee2mqtt_release_exclude }}"
|
|
extra_opts:
|
|
- --strip-components=1
|
|
|
|
- name: Delete existing node_modules folder
|
|
file:
|
|
path: "{{ zigbee2mqtt_base_dir }}/node_modules"
|
|
state: absent
|
|
|
|
- name: Install nodejs dependencies
|
|
npm:
|
|
path: "{{ zigbee2mqtt_base_dir }}"
|
|
environment:
|
|
PATH: "{{ __zigbee2mqtt_npm_executable | dirname }}:{{ ansible_env.PATH }}"
|
|
notify: __zigbee2mqtt_restart
|
|
when: zigbee2mqtt_version is version(zigbee2mqtt_current_version, ">")
|
|
become: True
|
|
become_user: "{{ zigbee2mqtt_user }}"
|
|
|
|
- block:
|
|
- name: Deploy configuration file
|
|
template:
|
|
src: "zigbee2mqtt/data/configuration.yaml.j2"
|
|
dest: "{{ zigbee2mqtt_base_dir }}/data/configuration.yaml"
|
|
mode: 0600
|
|
notify: __zigbee2mqtt_restart
|
|
|
|
- name: Ensure device files exists
|
|
file:
|
|
path: "{{ item }}"
|
|
state: touch
|
|
access_time: preserve
|
|
modification_time: preserve
|
|
loop:
|
|
- "{{ zigbee2mqtt_base_dir }}/data/devices.yaml"
|
|
- "{{ zigbee2mqtt_base_dir }}/data/groups.yaml"
|
|
become: True
|
|
become_user: "{{ zigbee2mqtt_user }}"
|
|
|
|
- block:
|
|
- name: Create systemd unit files
|
|
template:
|
|
src: "etc/systemd/system/zigbee2mqtt.service.j2"
|
|
dest: "/etc/systemd/system/zigbee2mqtt.service"
|
|
mode: 0644
|
|
notify: __zigbee2mqtt_restart
|
|
|
|
- name: Set current version to custom fact
|
|
template:
|
|
src: etc/ansible/facts.d/zigbee2mqtt.fact.j2
|
|
dest: /etc/ansible/facts.d/zigbee2mqtt.fact
|
|
mode: 0644
|
|
when: zigbee2mqtt_version is version(zigbee2mqtt_current_version, ">") or zigbee2mqtt_current_version is version('0.0.0', "=")
|
|
become: True
|
|
become_user: root
|