xoxys.zigbee2mqtt/tasks/install.yml

84 lines
2.5 KiB
YAML
Raw Normal View History

2018-11-11 02:11:10 +00:00
---
- name: Create directories
file:
path: "{{ item }}"
state: directory
owner: "{{ zigbee2mqtt_user }}"
group: "{{ zigbee2mqtt_group }}"
2019-08-08 11:50:15 +00:00
mode: 0750
2018-11-11 02:11:10 +00:00
with_items:
- "{{ zigbee2mqtt_base_dir }}"
2019-08-08 12:31:09 +00:00
- "{{ zigbee2mqtt_base_dir }}/data"
2019-08-08 11:50:15 +00:00
- "{{ zigbee2mqtt_log_dir }}"
2018-11-11 02:11:10 +00:00
become: True
become_user: root
- block:
2019-08-08 12:31:09 +00:00
- name: Download release 'v{{ zigbee2mqtt_version }}'
unarchive:
src: "https://github.com/Koenkk/zigbee2mqtt/archive/{{ zigbee2mqtt_version }}.tar.gz"
2018-11-11 02:11:10 +00:00
dest: "{{ zigbee2mqtt_base_dir }}"
2019-08-08 12:31:09 +00:00
remote_src: yes
exclude: "{{ __zigbee2mqtt_release_exclude }}"
extra_opts:
- --strip-components=1
2018-11-11 02:11:10 +00:00
2019-03-09 12:56:21 +00:00
- name: Delete existing node_modules folder
file:
path: "{{ zigbee2mqtt_base_dir }}/node_modules"
state: absent
2019-05-04 22:17:45 +00:00
- name: Install nodejs dependencies
2018-11-11 02:11:10 +00:00
npm:
path: "{{ zigbee2mqtt_base_dir }}"
2019-03-09 15:51:27 +00:00
environment:
2019-08-06 20:32:45 +00:00
PATH: "{{ __zigbee2mqtt_npm_executable | dirname }}:{{ ansible_env.PATH }}"
2018-11-11 02:11:10 +00:00
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
loop:
- "{{ zigbee2mqtt_base_dir }}/data/devices.yaml"
- "{{ zigbee2mqtt_base_dir }}/data/groups.yaml"
2019-08-08 11:50:15 +00:00
become: True
become_user: "{{ zigbee2mqtt_user }}"
2018-11-11 02:11:10 +00:00
- block:
2019-03-09 14:12:58 +00:00
- name: Create systemd unit files
template:
src: "etc/systemd/system/zigbee2mqtt.service.j2"
dest: "/etc/systemd/system/zigbee2mqtt.service"
mode: 0644
notify: __zigbee2mqtt_restart
2019-03-09 15:28:22 +00:00
- name: Copy logrotate config
template:
src: "etc/logrotate.d/config.j2"
dest: "/etc/logrotate.d/zigbee2mqtt"
loop: "{{ zigbee2mqtt_logrotate_config }}"
loop_control:
label: "{{ item.log }}"
when: zigbee2mqtt_logrotate_enabled | bool
2019-03-09 15:28:22 +00:00
- 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', "=")
2018-11-11 02:11:10 +00:00
become: True
become_user: root