xoxys.zigbee2mqtt/tasks/install.yml
Robert Kaussow 995264ef75
All checks were successful
continuous-integration/drone/push Build is passing
remove old loop syntax
2019-08-27 08:29:30 +02:00

86 lines
2.6 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: 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
- 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