2024-11-19 07:40:04 +01:00
|
|
|
- hosts: mqtt_srv
|
2024-06-08 22:23:49 +02:00
|
|
|
name: Install mqtt_srv
|
2024-07-09 02:05:42 +02:00
|
|
|
ignore_unreachable: false
|
2024-07-09 01:51:42 +02:00
|
|
|
ignore_errors: true
|
2024-06-08 22:23:49 +02:00
|
|
|
tasks:
|
2024-10-12 23:42:49 +02:00
|
|
|
# - name: Install python3-pip
|
|
|
|
# ansible.builtin.apt:
|
|
|
|
# name:
|
|
|
|
# - python3-pip
|
|
|
|
# update_cache: yes
|
2024-07-09 00:58:19 +02:00
|
|
|
|
2024-10-12 23:42:49 +02:00
|
|
|
# when: inventory_hostname not in groups['nas'] and inventory_hostname not in groups['router']
|
|
|
|
# become: "{{ 'no' if inventory_hostname in groups['nas'] else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
2024-11-19 07:53:39 +01:00
|
|
|
- debug:
|
|
|
|
msg: "{{ inventory_hostname }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
2024-06-08 22:23:49 +02:00
|
|
|
- name: Upload service config
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: services/mqtt_srv.service
|
|
|
|
dest: /etc/systemd/system/
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
|
|
|
|
2024-07-09 00:21:30 +02:00
|
|
|
|
2024-06-08 22:23:49 +02:00
|
|
|
- name: Upload service script
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: scripts/mqtt_srv.py
|
|
|
|
dest: /usr/bin/
|
2024-06-08 22:31:52 +02:00
|
|
|
mode: '755'
|
2024-06-08 22:34:41 +02:00
|
|
|
owner: root
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-11-19 07:56:57 +01:00
|
|
|
|
2024-10-30 12:14:02 +01:00
|
|
|
- name: Upload service script config
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: scripts/mqtt_srv.cfg
|
2024-10-30 12:17:23 +01:00
|
|
|
dest: /etc/mqtt_srv/
|
2024-10-30 12:14:02 +01:00
|
|
|
mode: '755'
|
|
|
|
owner: root
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-11-19 07:29:48 +01:00
|
|
|
# - name: Upload service script1
|
|
|
|
# ansible.builtin.copy:
|
|
|
|
# src: scripts/mqtt_srv.sh
|
|
|
|
# dest: /jffs/scripts/mqtt_srv/
|
|
|
|
# mode: '755'
|
|
|
|
# owner: admin
|
|
|
|
# when: inventory_hostname in groups['router']
|
|
|
|
# become: false
|
|
|
|
|
|
|
|
|
|
|
|
# - name: Upload service script
|
|
|
|
# ansible.builtin.copy:
|
|
|
|
# src: scripts/mqtt_srv.py
|
|
|
|
# dest: /jffs/scripts/mqtt_srv/
|
|
|
|
# mode: '755'
|
|
|
|
# owner: admin
|
|
|
|
# when: inventory_hostname in groups['router']
|
|
|
|
# become: false
|
2024-07-09 00:21:30 +02:00
|
|
|
|
2024-07-08 22:39:36 +02:00
|
|
|
- name: Upload service script1
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: scripts/mqtt_srv.sh
|
|
|
|
dest: /etc/init.d/
|
|
|
|
mode: '755'
|
|
|
|
owner: admin
|
2024-11-19 07:56:57 +01:00
|
|
|
when: inventory_hostname == 'nas.home.lan'
|
2024-11-19 07:53:39 +01:00
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-08 22:39:36 +02:00
|
|
|
|
|
|
|
- name: Upload service script2
|
2024-07-07 22:41:10 +02:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: scripts/mqtt_srv.py
|
2024-07-08 22:39:36 +02:00
|
|
|
dest: /usr/bin/
|
2024-07-07 22:41:10 +02:00
|
|
|
mode: '755'
|
|
|
|
owner: admin
|
2024-11-19 07:56:57 +01:00
|
|
|
when: inventory_hostname == 'router.home.lan'
|
2024-11-19 07:53:39 +01:00
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
2024-06-08 22:34:41 +02:00
|
|
|
- name: Install bottle python package
|
2024-06-27 00:19:16 +02:00
|
|
|
ansible.builtin.shell: pip install {{ item }} --break-system-packages
|
|
|
|
loop:
|
|
|
|
- paho-mqtt
|
|
|
|
- getmac
|
|
|
|
- ping3
|
|
|
|
- psutil
|
|
|
|
- autorandr
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
|
|
|
|
2024-06-08 23:47:29 +02:00
|
|
|
- name: Just force systemd to reread configs (2.4 and above)
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: true
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
|
|
|
|
2024-06-08 23:47:29 +02:00
|
|
|
- name: Restart mqtt_srv service
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: mqtt_srv.service
|
2024-07-07 22:32:10 +02:00
|
|
|
state: restarted
|
2024-09-20 14:56:09 +02:00
|
|
|
enabled: true
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:41:10 +02:00
|
|
|
|
2024-07-08 22:58:17 +02:00
|
|
|
- name: Restart mqtt service
|
2024-07-08 22:39:36 +02:00
|
|
|
ansible.builtin.shell: "(/etc/init.d/mqtt_srv.sh restart >/dev/null 2>&1 &)"
|
2024-07-07 23:18:55 +02:00
|
|
|
async: 10
|
|
|
|
poll: 0
|
2024-11-19 07:53:39 +01:00
|
|
|
when: inventory_hostname != 'nas.home.lan'
|
|
|
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
2024-07-07 22:46:28 +02:00
|
|
|
|