Move become: true into esphome role

Move become: true into zigbee2mqtt role

Remove become: true from deploy_public_reverse_proxy playbook

Remove become: true from deploy_dokuwiki playbook

Move become: true from deploy_audio_pi and deploy_light playbooks into roles

Remove become: true from deploy_keycloak playbook

Move become: true from deploy_automation playbook to mosquitto role
This commit is contained in:
yuri 2023-05-09 21:12:46 +02:00
parent b56ca3899d
commit 33d1cfca1f
No known key found for this signature in database
GPG key ID: E646779AC54AEC64
24 changed files with 119 additions and 20 deletions

View file

@ -1,6 +1,5 @@
--- ---
- name: Configure audio.z9 as a bluetooth audio sink and AirPlay server - name: Configure audio.z9 as a bluetooth audio sink and AirPlay server
become: true
hosts: audio hosts: audio
roles: roles:
- hifiberry - hifiberry

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy mosquitto MQTT broker on automation.z9 - name: Deploy mosquitto MQTT broker on automation.z9
become: true
hosts: automation hosts: automation
roles: roles:
- mosquitto - mosquitto

View file

@ -1,6 +1,5 @@
--- ---
- name: Configure wiki.z9 with dokuwiki - name: Configure wiki.z9 with dokuwiki
become: true
hosts: wiki hosts: wiki
roles: roles:
- nginx - nginx

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy esphome on esphome.z9 - name: Deploy esphome on esphome.z9
become: true
hosts: esphome hosts: esphome
roles: roles:
- esphome - esphome

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy nginx and keycloak using docker_compose on keyloak - name: Deploy nginx and keycloak using docker_compose on keyloak
become: true
hosts: keycloak hosts: keycloak
roles: roles:
- cert - cert

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy ola and foobazdmx on light.z9 - name: Deploy ola and foobazdmx on light.z9
become: true
hosts: light hosts: light
roles: roles:
- ola - ola

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy the Public-Reverse-Proxy - name: Deploy the Public-Reverse-Proxy
hosts: public-reverse-proxy hosts: public-reverse-proxy
become: true
roles: roles:
- nginx - nginx

View file

@ -1,6 +1,5 @@
--- ---
- name: Deploy zigbee2mqtt on zigbee2mqtt.z9.ccchh.net - name: Deploy zigbee2mqtt on zigbee2mqtt.z9.ccchh.net
become: true
hosts: zigbee2mqtt hosts: zigbee2mqtt
roles: roles:
- zigbee2mqtt - zigbee2mqtt

View file

@ -3,22 +3,30 @@
ansible.builtin.fail: ansible.builtin.fail:
msg: "Can only add apt repositories on Debian-based systems!" msg: "Can only add apt repositories on Debian-based systems!"
when: ansible_facts.os_family != "Debian" when: ansible_facts.os_family != "Debian"
- name: Install required apt packages for adding an apt repository - name: Install required apt packages for adding an apt repository
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- ca-certificates - ca-certificates
- gnupg - gnupg
- name: Install apt-transport-https if https repository - name: Install apt-transport-https if https repository
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: apt-transport-https name: apt-transport-https
when: add_apt_repository__https_repo when: add_apt_repository__https_repo
- name: Add repository signing key to keychain - name: Add repository signing key to keychain
become: true
when: add_apt_repository__keyring_url is defined and add_apt_repository__keyring_path is defined when: add_apt_repository__keyring_url is defined and add_apt_repository__keyring_path is defined
ansible.builtin.apt_key: ansible.builtin.apt_key:
url: "{{ add_apt_repository__keyring_url }}" url: "{{ add_apt_repository__keyring_url }}"
keyring: "{{ add_apt_repository__keyring_path }}" keyring: "{{ add_apt_repository__keyring_path }}"
state: present state: present
- name: Add repository and update cache - name: Add repository and update cache
become: true
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: "{{ add_apt_repository__repo }}" repo: "{{ add_apt_repository__repo }}"
filename: "{{ add_apt_repository__filename }}" filename: "{{ add_apt_repository__filename }}"

View file

@ -1,45 +1,60 @@
--- ---
- name: Ensure acl is installed - name: Ensure acl is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: acl name: acl
- name: Ensure machine-info file is deployed - name: Ensure machine-info file is deployed
become: true
ansible.builtin.template: ansible.builtin.template:
src: machine-info.j2 src: machine-info.j2
dest: /etc/machine-info dest: /etc/machine-info
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Restart bluetooth service notify: Restart bluetooth service
- name: Ensure bluetooth config is deployed - name: Ensure bluetooth config is deployed
become: true
ansible.builtin.template: ansible.builtin.template:
src: main.conf.j2 src: main.conf.j2
dest: /etc/bluetooth/main.conf dest: /etc/bluetooth/main.conf
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Restart bluetooth service notify: Restart bluetooth service
- name: Ensure bluetooth service is enabled and started - name: Ensure bluetooth service is enabled and started
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: bluetooth.service service: bluetooth.service
state: started state: started
enabled: true enabled: true
- name: Ensure audiosink user exists - name: Ensure audiosink user exists
become: true
ansible.builtin.user: ansible.builtin.user:
name: audiosink name: audiosink
groups: groups:
- audio - audio
- name: Ensure user services are started without needing to login - name: Ensure user services are started without needing to login
become: true
ansible.builtin.command: ansible.builtin.command:
cmd: loginctl enable-linger audiosink cmd: loginctl enable-linger audiosink
changed_when: false changed_when: false
- name: Detect if on Raspberry Pi # noqa ignore-errors - name: Detect if on Raspberry Pi # noqa ignore-errors
ansible.builtin.include_role: ansible.builtin.include_role:
name: raspberry_pi_check name: raspberry_pi_check
ignore_errors: true ignore_errors: true
- name: Ensure debian archive keyring is installed # noqa no-handler - name: Ensure debian archive keyring is installed # noqa no-handler
become: true
when: raspberry_pi_check__cpuinfo.found when: raspberry_pi_check__cpuinfo.found
ansible.builtin.apt: ansible.builtin.apt:
deb: https://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1_all.deb deb: https://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1_all.deb
- name: Ensure debian backports repository is enabled - name: Ensure debian backports repository is enabled
ansible.builtin.include_role: ansible.builtin.include_role:
name: add_apt_repository name: add_apt_repository
@ -47,94 +62,120 @@
add_apt_repository__https_repo: false add_apt_repository__https_repo: false
add_apt_repository__repo: "deb http://deb.debian.org/debian {{ ansible_facts.lsb.codename }}-backports main contrib non-free" add_apt_repository__repo: "deb http://deb.debian.org/debian {{ ansible_facts.lsb.codename }}-backports main contrib non-free"
add_apt_repository__filename: "{{ ansible_facts.lsb.codename }}-backports.list" add_apt_repository__filename: "{{ ansible_facts.lsb.codename }}-backports.list"
- name: Ensure pipewire, wireplumber and libspa-0.2-bluetooth are installed - name: Ensure pipewire, wireplumber and libspa-0.2-bluetooth are installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- pipewire - pipewire
- wireplumber - wireplumber
- libspa-0.2-bluetooth - libspa-0.2-bluetooth
default_release: "{{ ansible_facts.lsb.codename }}-backports" default_release: "{{ ansible_facts.lsb.codename }}-backports"
- name: Ensure pipewire user service is enabled and started - name: Ensure pipewire user service is enabled and started
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.systemd: ansible.builtin.systemd:
name: pipewire.service name: pipewire.service
state: started state: started
enabled: true enabled: true
scope: user scope: user
- name: Ensure pipewire-pulse user service is enabled and started - name: Ensure pipewire-pulse user service is enabled and started
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.systemd: ansible.builtin.systemd:
name: pipewire-pulse.service name: pipewire-pulse.service
state: started state: started
enabled: true enabled: true
scope: user scope: user
- name: Ensure wireplumber user service is enabled - name: Ensure wireplumber user service is enabled
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.systemd: ansible.builtin.systemd:
name: wireplumber.service name: wireplumber.service
enabled: true enabled: true
scope: user scope: user
- name: Ensure speaker-agent dependencies are installed - name: Ensure speaker-agent dependencies are installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- git - git
- python3-dbus - python3-dbus
- name: Ensure speaker-agent repository is cloned - name: Ensure speaker-agent repository is cloned
become: true
ansible.builtin.git: ansible.builtin.git:
repo: https://github.com/fdanis-oss/pw_wp_bluetooth_rpi_speaker.git repo: https://github.com/fdanis-oss/pw_wp_bluetooth_rpi_speaker.git
dest: /opt/speaker-agent dest: /opt/speaker-agent
version: 9a939a23865ea020816017e06fd2290f301c35f9 version: 9a939a23865ea020816017e06fd2290f301c35f9
- name: Ensure .config directory exists - name: Ensure .config directory exists
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.file: ansible.builtin.file:
path: /home/audiosink/.config path: /home/audiosink/.config
state: directory state: directory
mode: 0700 mode: "700"
owner: audiosink owner: audiosink
group: audiosink group: audiosink
- name: Ensure .config/systemd directory exists - name: Ensure .config/systemd directory exists
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.file: ansible.builtin.file:
path: /home/audiosink/.config/systemd path: /home/audiosink/.config/systemd
state: directory state: directory
mode: 0755 mode: "755"
owner: audiosink owner: audiosink
group: audiosink group: audiosink
- name: Ensure .config/systemd/user directory exists - name: Ensure .config/systemd/user directory exists
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.file: ansible.builtin.file:
path: /home/audiosink/.config/systemd/user path: /home/audiosink/.config/systemd/user
state: directory state: directory
mode: 0755 mode: "755"
owner: audiosink owner: audiosink
group: audiosink group: audiosink
- name: Ensure speaker-agent service file is deployed - name: Ensure speaker-agent service file is deployed
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.copy: ansible.builtin.copy:
src: speaker-agent.service src: speaker-agent.service
dest: /home/audiosink/.config/systemd/user/speaker-agent.service dest: /home/audiosink/.config/systemd/user/speaker-agent.service
mode: 0644 mode: "644"
owner: audiosink owner: audiosink
group: audiosink group: audiosink
notify: Restart speaker-agent service notify: Restart speaker-agent service
- name: Ensure speaker-agent service is enabled and started - name: Ensure speaker-agent service is enabled and started
become: true
become_user: audiosink become_user: audiosink
ansible.builtin.systemd: ansible.builtin.systemd:
name: speaker-agent.service name: speaker-agent.service
state: started state: started
enabled: true enabled: true
scope: user scope: user
# This part is janky, but I don't know how to make the bluetooth service, wireplumber and pipewire # This part is janky, but I don't know how to make the bluetooth service, wireplumber and pipewire
# work with each other without being logged in. # work with each other without being logged in.
- name: Ensure getty@tty1 override file is deployed - name: Ensure getty@tty1 override file is deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
src: override.conf src: override.conf
dest: /etc/systemd/system/getty@tty1.service.d/override.conf dest: /etc/systemd/system/getty@tty1.service.d/override.conf
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Reboot host notify: Reboot host
- name: Ensure autologin for audiosink user is enabled - name: Ensure autologin for audiosink user is enabled
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: getty@tty1.service service: getty@tty1.service
enabled: true enabled: true

View file

@ -1,5 +1,6 @@
--- ---
- name: Restart esphome - name: Restart esphome
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: esphome.service service: esphome.service
state: restarted state: restarted

View file

@ -1,33 +1,40 @@
- name: Ensure acl is installed - name: Ensure acl is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: acl name: acl
- name: Ensure pip is installed - name: Ensure pip is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: python3-pip name: python3-pip
- name: Ensure esphome user exists - name: Ensure esphome user exists
become: true
ansible.builtin.user: ansible.builtin.user:
name: esphome name: esphome
shell: /bin/bash shell: /bin/bash
- name: Ensure esphome dependencies are installed - name: Ensure esphome dependencies are installed
become: true
become_user: esphome become_user: esphome
ansible.builtin.pip: ansible.builtin.pip:
name: tornado name: tornado
extra_args: --user extra_args: --user
- name: Ensure esphome is installed - name: Ensure esphome is installed
become: true
become_user: esphome become_user: esphome
ansible.builtin.pip: ansible.builtin.pip:
name: "esphome=={{ esphome__version }}" name: "esphome=={{ esphome__version }}"
extra_args: --user extra_args: --user
notify: Restart esphome notify: Restart esphome
- name: Ensure esphome systemd service file is deployed - name: Ensure esphome systemd service file is deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
src: esphome.service src: esphome.service
dest: /etc/systemd/system/esphome.service dest: /etc/systemd/system/esphome.service
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Restart esphome notify: Restart esphome
- name: Ensure esphome service is enabled and started - name: Ensure esphome service is enabled and started
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: esphome.service service: esphome.service
enabled: true enabled: true

View file

@ -1,4 +1,5 @@
- name: Restart foobazdmx - name: Restart foobazdmx
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: foobazdmx.service service: foobazdmx.service
state: restarted state: restarted

View file

@ -1,4 +1,5 @@
- name: Ensure apt dependencies are installed - name: Ensure apt dependencies are installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- acl - acl
@ -6,32 +7,41 @@
- python3 - python3
- python3-pip - python3-pip
- python3-setuptools - python3-setuptools
- name: Ensure python peotry is installed - name: Ensure python peotry is installed
become: true
ansible.builtin.pip: ansible.builtin.pip:
name: poetry name: poetry
- name: Ensure foobazdmx user exists - name: Ensure foobazdmx user exists
become: true
ansible.builtin.user: ansible.builtin.user:
name: foobazdmx name: foobazdmx
- name: Install foobazdmx - name: Install foobazdmx
notify: Restart foobazdmx notify: Restart foobazdmx
block: block:
- name: Clone foobazdmx repository - name: Clone foobazdmx repository
become: true
ansible.builtin.git: ansible.builtin.git:
repo: https://thinkcccentre-ansible:glpat-VegCzyjuDjB19SggAqm1@gitlab.hamburg.ccc.de/yuri/foobazdmx.git repo: https://thinkcccentre-ansible:glpat-VegCzyjuDjB19SggAqm1@gitlab.hamburg.ccc.de/yuri/foobazdmx.git
dest: /opt/foobazdmx dest: /opt/foobazdmx
version: bf6170aa12fa5de9b9667be9b744ad7ee6157dde version: bf6170aa12fa5de9b9667be9b744ad7ee6157dde
- name: Install python dependencies - name: Install python dependencies
become: true
become_user: foobazdmx become_user: foobazdmx
ansible.builtin.command: ansible.builtin.command:
cmd: poetry install cmd: poetry install
chdir: /opt/foobazdmx chdir: /opt/foobazdmx
changed_when: false changed_when: false
- name: Generate foobazdmx service file - name: Generate foobazdmx service file
become: true
ansible.builtin.template: ansible.builtin.template:
src: foobazdmx.service.j2 src: foobazdmx.service.j2
dest: /etc/systemd/system/foobazdmx.service dest: /etc/systemd/system/foobazdmx.service
mode: "0755" mode: "0755"
- name: Enable and start foobazdmx service - name: Enable and start foobazdmx service
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: foobazdmx.service service: foobazdmx.service
state: started state: started

View file

@ -1,3 +1,4 @@
--- ---
- name: Restart system - name: Restart system
become: true
ansible.builtin.reboot: ansible.builtin.reboot:

View file

@ -1,17 +1,22 @@
--- ---
- name: Remove dtparam=audio=on - name: Remove dtparam=audio=on
become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
line: dtparam=audio=on line: dtparam=audio=on
dest: /boot/config.txt dest: /boot/config.txt
state: absent state: absent
notify: Restart system notify: Restart system
- name: Set audio=off for dtoverlay=vc4-kms-v3d - name: Set audio=off for dtoverlay=vc4-kms-v3d
become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
regexp: ^dtoverlay=vc4-kms-v3d regexp: ^dtoverlay=vc4-kms-v3d
line: dtoverlay=vc4-kms-v3d,audio=off line: dtoverlay=vc4-kms-v3d,audio=off
dest: /boot/config.txt dest: /boot/config.txt
notify: Restart system notify: Restart system
- name: Add hifiberry dtoverlay - name: Add hifiberry dtoverlay
become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
line: "dtoverlay={{ hifiberry__device }}" line: "dtoverlay={{ hifiberry__device }}"
dest: /boot/config.txt dest: /boot/config.txt

View file

@ -1,5 +1,6 @@
--- ---
- name: Restart mosquitto - name: Restart mosquitto
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: mosquitto.service service: mosquitto.service
state: restarted state: restarted

View file

@ -1,25 +1,32 @@
--- ---
- name: Ensure mosquitto is installed - name: Ensure mosquitto is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: mosquitto name: mosquitto
- name: Ensure main configuraton file is deployed - name: Ensure main configuraton file is deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ mosquitto__mosquitto_conf_content }}" content: "{{ mosquitto__mosquitto_conf_content }}"
dest: /etc/mosquitto/mosquitto.conf dest: /etc/mosquitto/mosquitto.conf
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Restart mosquitto notify: Restart mosquitto
- name: Ensure all additional configuraton files are deployed - name: Ensure all additional configuraton files are deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ item.content }}" content: "{{ item.content }}"
dest: /etc/mosquitto/conf.d/{{ item.name }}.conf dest: /etc/mosquitto/conf.d/{{ item.name }}.conf
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
loop: "{{ mosquitto__configs }}" loop: "{{ mosquitto__configs }}"
notify: Restart mosquitto notify: Restart mosquitto
- name: Ensure mosquitto service is enabled and started - name: Ensure mosquitto service is enabled and started
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: mosquitto.service service: mosquitto.service
enabled: true enabled: true

View file

@ -1,4 +1,5 @@
- name: Restart olad - name: Restart olad
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: olad.service service: olad.service
state: restarted state: restarted

View file

@ -1,16 +1,21 @@
- name: Install ola - name: Install ola
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: ola name: ola
- name: Ensure all given configuraton files are deployed - name: Ensure all given configuraton files are deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ item.content }}" content: "{{ item.content }}"
dest: /etc/ola/{{ item.name }}.conf dest: /etc/ola/{{ item.name }}.conf
mode: 0644 mode: "644"
owner: olad owner: olad
group: olad group: olad
loop: "{{ ola__configs }}" loop: "{{ ola__configs }}"
notify: Restart olad notify: Restart olad
- name: Enable and start ola service - name: Enable and start ola service
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
name: olad.service name: olad.service
state: started state: started

View file

@ -1,5 +1,6 @@
--- ---
- name: Restart shairport-sync service - name: Restart shairport-sync service
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: shairport-sync service: shairport-sync
state: restarted state: restarted

View file

@ -1,16 +1,21 @@
--- ---
- name: Ensure shairport-sync is installed - name: Ensure shairport-sync is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: shairport-sync name: shairport-sync
- name: Ensure shairport-sync config is deployed - name: Ensure shairport-sync config is deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ shairport_sync__config }}" content: "{{ shairport_sync__config }}"
dest: /etc/shairport-sync.conf dest: /etc/shairport-sync.conf
mode: 0644 mode: "644"
owner: root owner: root
group: root group: root
notify: Restart shairport-sync service notify: Restart shairport-sync service
- name: Ensure shairport-sync service is enabled and started - name: Ensure shairport-sync service is enabled and started
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: shairport-sync service: shairport-sync
state: started state: started

View file

@ -1,8 +1,11 @@
- name: Restart zigbee2mqtt - name: Restart zigbee2mqtt
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
name: zigbee2mqtt name: zigbee2mqtt
state: restarted state: restarted
- name: Reload systemd-daemon and restart zigbee2mqtt - name: Reload systemd-daemon and restart zigbee2mqtt
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
name: zigbee2mqtt name: zigbee2mqtt
state: restarted state: restarted

View file

@ -1,12 +1,15 @@
- name: Ensure acl is installed - name: Ensure acl is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: acl name: acl
- name: Ensure git is installed - name: Ensure git is installed
become: true
ansible.builtin.apt: ansible.builtin.apt:
name: git name: git
- name: Ensure zigbee2mqtt user exists - name: Ensure zigbee2mqtt user exists
become: true
ansible.builtin.user: ansible.builtin.user:
name: zigbee2mqtt name: zigbee2mqtt
groups: groups:
@ -15,6 +18,7 @@
group: zigbee2mqtt group: zigbee2mqtt
- name: Ensure installation directory exists - name: Ensure installation directory exists
become: true
ansible.builtin.file: ansible.builtin.file:
dest: /opt/zigbee2mqtt dest: /opt/zigbee2mqtt
state: directory state: directory
@ -23,6 +27,7 @@
group: zigbee2mqtt group: zigbee2mqtt
- name: Ensure zigbee2mqtt repository is cloned - name: Ensure zigbee2mqtt repository is cloned
become: true
become_user: zigbee2mqtt become_user: zigbee2mqtt
ansible.builtin.git: ansible.builtin.git:
repo: https://github.com/Koenkk/zigbee2mqtt.git repo: https://github.com/Koenkk/zigbee2mqtt.git
@ -32,6 +37,7 @@
notify: Restart zigbee2mqtt notify: Restart zigbee2mqtt
- name: Ensure npm dependencies are installed - name: Ensure npm dependencies are installed
become: true
become_user: zigbee2mqtt become_user: zigbee2mqtt
community.general.npm: community.general.npm:
path: /opt/zigbee2mqtt path: /opt/zigbee2mqtt
@ -39,6 +45,7 @@
changed_when: false # installs packages according to package-lock.json, but always reports a change changed_when: false # installs packages according to package-lock.json, but always reports a change
- name: Ensure custom zigbee2mqtt data directory exists - name: Ensure custom zigbee2mqtt data directory exists
become: true
ansible.builtin.file: ansible.builtin.file:
dest: /home/zigbee2mqtt/zigbee2mqtt_data dest: /home/zigbee2mqtt/zigbee2mqtt_data
state: directory state: directory
@ -52,6 +59,7 @@
register: zigbee2mqtt__conf_stat register: zigbee2mqtt__conf_stat
- name: Ensure configuration file is deployed when it doesn't exist - name: Ensure configuration file is deployed when it doesn't exist
become: true
when: not zigbee2mqtt__conf_stat.stat.exists when: not zigbee2mqtt__conf_stat.stat.exists
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ zigbee2mqtt__config }}" content: "{{ zigbee2mqtt__config }}"
@ -62,6 +70,7 @@
notify: Restart zigbee2mqtt notify: Restart zigbee2mqtt
- name: Ensure zigbee2mqtt service file is deployed - name: Ensure zigbee2mqtt service file is deployed
become: true
ansible.builtin.copy: ansible.builtin.copy:
src: zigbee2mqtt.service src: zigbee2mqtt.service
dest: /etc/systemd/system/zigbee2mqtt.service dest: /etc/systemd/system/zigbee2mqtt.service
@ -71,6 +80,7 @@
notify: Reload systemd-daemon and restart zigbee2mqtt notify: Reload systemd-daemon and restart zigbee2mqtt
- name: Ensure zigbee2mqtt is enabled and started - name: Ensure zigbee2mqtt is enabled and started
become: true
ansible.builtin.systemd: ansible.builtin.systemd:
service: zigbee2mqtt service: zigbee2mqtt
enabled: true enabled: true