feat: notifiers role

main
Ricard Illa 2023-05-09 09:56:59 +02:00
parent 8b3c6c7553
commit c0fcf3238d
5 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#!/bin/sh
# shellcheck disable=SC1091
. /usr/local/etc/notifiers/gotify
PRIORITY="${PRIORITY:-5}"
if [ -n "$TITLE" ]; then
TITLE_ARG="--form title=${TITLE}"
else
TITLE_ARG=""
fi
MSG="$*"
# shellcheck disable=SC2086
curl \
"${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
$TITLE_ARG \
--form "message=${MSG}" \
--form "priority=${PRIORITY}"

View File

@ -0,0 +1,12 @@
#!/bin/sh
# shellcheck disable=SC1091
. /usr/local/etc/notifiers/xmpp
MSG="$*"
echo "$MSG" |
go-sendxmpp \
--username="$XMPP_ACCOUNT" \
--password="$XMPP_PASSWORD" \
"$XMPP_RECIPIENT"

View File

@ -0,0 +1,33 @@
---
- name: install notification programs
apk:
name:
- curl
- go-sendxmpp
- msmtp
when: ansible_distribution == "Alpine"
- name: create config dir
file:
state: directory
path: /usr/local/etc/notifiers
- name: render notifier configs
template:
src: "etc/notifiers/{{ item }}.j2"
dest: "/usr/local/etc/notifiers/{{ item }}"
owner: root
mode: '0600'
loop:
- gotify
- xmpp
- name: copy notifier executables
copy:
src: "bin/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
mode: '0755'
loop:
- notify-gotify
- notify-xmpp

View File

@ -0,0 +1,2 @@
GOTIFY_URL='{{ notifiers.gotify.url }}'
GOTIFY_TOKEN='{{ notifiers.gotify.token }}'

View File

@ -0,0 +1,3 @@
XMPP_RECIPIENT='{{ notifiers.xmpp.recipient }}'
XMPP_ACCOUNT='{{ notifiers.xmpp.account }}'
XMPP_PASSWORD='{{ notifiers.xmpp.password }}'