From 95c66d976fe9b61e74ec9b2aac61b3aa10eb2b56 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 5 Apr 2025 16:35:24 +0000 Subject: [PATCH] Add mqtt-tail script to adm hosts --- playbooks/adm.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/playbooks/adm.yml b/playbooks/adm.yml index 69cfb42..3c2bd6c 100644 --- a/playbooks/adm.yml +++ b/playbooks/adm.yml @@ -53,6 +53,7 @@ - libvirt-client # kvm host client - make # generic building - mariadb # mariadb client tools + - mosquitto # mqtt reading - nano # more editors - nmap # check for open ports - nsd # check dns zone files @@ -113,3 +114,27 @@ state: link owner: root group: "{{ ansible_wheel }}" + + - name: Add mqtt-tail script + ansible.builtin.copy: + dest: /usr/local/bin/mqtt-tail + content: | + #!/bin/sh + set -eu + if [ -n "${1:-}" ]; then + topic="$1" + shift + else + topic="#" + fi + if [ $# -ne 0 ]; then + echo "Usage: $(basename "$0") [topic]" 1>&2 + exit 1 + fi + exec mosquitto_sub -h mqtt02.home.foo.sh -v -t "$topic" \ + --cafile "{{ tls_certs }}/ca.crt" \ + --cert "{{ tls_certs }}/{{ inventory_hostname }}.crt" \ + --key "{{ tls_private }}/{{ inventory_hostname }}.key" \ + mode: "0755" + owner: root + group: "{{ ansible_wheel }}"