add service state variables
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2019-08-08 22:52:37 +02:00
parent 98d6dd8fe1
commit d79aef473f
5 changed files with 18 additions and 65 deletions

View File

@ -7,6 +7,9 @@ zigbee2mqtt_secondary_groups:
- tty - tty
- dialout - dialout
zigbee2mqtt_service_state: started
zigbee2mqtt_service_restart_state: restarted
zigbee2mqtt_base_dir: /opt/zigbee2mqtt zigbee2mqtt_base_dir: /opt/zigbee2mqtt
zigbee2mqtt_log_dir: "{{ zigbee2mqtt_base_dir }}/log" zigbee2mqtt_log_dir: "{{ zigbee2mqtt_base_dir }}/log"
zigbee2mqtt_log_level: info zigbee2mqtt_log_level: info

View File

@ -1,7 +1,7 @@
--- ---
- name: Restart zigbee2mqtt service - name: Restart zigbee2mqtt service
systemd: systemd:
state: restarted state: "{{ zigbee2mqtt_service_restart_state }}"
daemon_reload: yes daemon_reload: yes
name: zigbee2mqtt name: zigbee2mqtt
listen: __zigbee2mqtt_restart listen: __zigbee2mqtt_restart

View File

@ -5,6 +5,8 @@
mosquitto_packages_extra: mosquitto_packages_extra:
- epel-release - epel-release
mosquitto_bind_address: "127.0.0.1" mosquitto_bind_address: "127.0.0.1"
zigbee2mqtt_service_state: stopped
zigbee2mqtt_service_restart_state: stopped
roles: roles:
- role: xoxys.mosquitto - role: xoxys.mosquitto

View File

@ -14,35 +14,6 @@
become_user: root become_user: root
- block: - block:
# - name: Check data dir
# stat:
# path: "{{ zigbee2mqtt_base_dir }}/data"
# register: __zigbee_datadir
# - name: Backup data directory
# synchronize:
# src: "{{ zigbee2mqtt_base_dir }}/data/"
# dest: "/tmp/zigbee_data"
# recursive: yes
# delegate_to: "{{ inventory_hostname }}"
# when: __zigbee_datadir.stat.exists
# - name: Setup zigbee2mqtt
# git:
# repo: "https://github.com/Koenkk/zigbee2mqtt"
# dest: "{{ zigbee2mqtt_base_dir }}/bin"
# version: "{{ zigbee2mqtt_version }}"
# force: yes
# register: __zigbee2mqtt_install
# - name: Restore data directory
# synchronize:
# src: "/tmp/zigbee_data/"
# dest: "{{ zigbee2mqtt_base_dir }}/data"
# recursive: yes
# delegate_to: "{{ inventory_hostname }}"
# when: __zigbee_datadir.stat.exists
- name: Download release 'v{{ zigbee2mqtt_version }}' - name: Download release 'v{{ zigbee2mqtt_version }}'
unarchive: unarchive:
src: "https://github.com/Koenkk/zigbee2mqtt/archive/{{ zigbee2mqtt_version }}.tar.gz" src: "https://github.com/Koenkk/zigbee2mqtt/archive/{{ zigbee2mqtt_version }}.tar.gz"
@ -52,8 +23,6 @@
extra_opts: extra_opts:
- --strip-components=1 - --strip-components=1
register: __zigbee2mqtt_install
- name: Delete existing node_modules folder - name: Delete existing node_modules folder
file: file:
path: "{{ zigbee2mqtt_base_dir }}/node_modules" path: "{{ zigbee2mqtt_base_dir }}/node_modules"
@ -69,27 +38,12 @@
become: True become: True
become_user: "{{ zigbee2mqtt_user }}" become_user: "{{ zigbee2mqtt_user }}"
- block: - name: Deploy configuration file
# - name: Cleanup base directory template:
# file: src: "zigbee2mqtt/data/configuration.yaml.j2"
# path: "{{ zigbee2mqtt_base_dir }}/{{ item }}" dest: "{{ zigbee2mqtt_base_dir }}/data/configuration.yaml"
# state: absent mode: 0600
# loop: notify: __zigbee2mqtt_restart
# - docker
# - docs
# - images
# - LICENSE
# - README.md
# - scripts
# - test
# - update.sh
- name: Deploy configuration file
template:
src: "zigbee2mqtt/data/configuration.yaml.j2"
dest: "{{ zigbee2mqtt_base_dir }}/data/configuration.yaml"
mode: 0600
notify: __zigbee2mqtt_restart
become: True become: True
become_user: "{{ zigbee2mqtt_user }}" become_user: "{{ zigbee2mqtt_user }}"

View File

@ -1,15 +1,9 @@
--- ---
- block: - name: Ensure zigbee2mqtt service is up and running
- name: Ensure zigbee2mqtt service is up and running systemd:
systemd: state: "{{ zigbee2mqtt_service_state }}"
state: started daemon_reload: yes
daemon_reload: yes enabled: yes
enabled: yes name: zigbee2mqtt
name: zigbee2mqtt
# - name: Delete backup data directory
# file:
# path: "/tmp/zigbee_data"
# state: absent
become: True become: True
become_user: root become_user: root