diff --git a/bootstrap-daemon/pvcbootstrapd.yaml.sample b/bootstrap-daemon/pvcbootstrapd.yaml.sample index a97e825..2be8767 100644 --- a/bootstrap-daemon/pvcbootstrapd.yaml.sample +++ b/bootstrap-daemon/pvcbootstrapd.yaml.sample @@ -106,6 +106,9 @@ pvc: success: "✅" # A task succeeded failure: "❌" # A task failed completed: "👌" # A task is completed + # A trigger word (no whitespace) added to the end of the completed cluster message; this can be used + # for pings in various chat systems (e.g. Mattermost) + completed_triggerword: "#pvcbootstrapcompleted" # The webhook body elements; this is specific to the webhook target, and is converted into raw # JSON before sending. # Two special variables are used: "{icon}" displays one of the above icons, and "{message}" displays diff --git a/bootstrap-daemon/pvcbootstrapd.yaml.template b/bootstrap-daemon/pvcbootstrapd.yaml.template index af12c43..075df41 100644 --- a/bootstrap-daemon/pvcbootstrapd.yaml.template +++ b/bootstrap-daemon/pvcbootstrapd.yaml.template @@ -35,6 +35,7 @@ pvc: enabled: false uri: https://mattermost.domain.tld/hooks/asecretstring action: post + completed_triggerword: "#pvcbootstrapcompleted" icons: info: "❕" # A note about an event begin: "🤞" # A task is beginning diff --git a/bootstrap-daemon/pvcbootstrapd/Daemon.py b/bootstrap-daemon/pvcbootstrapd/Daemon.py index 9870af7..2acb2fa 100755 --- a/bootstrap-daemon/pvcbootstrapd/Daemon.py +++ b/bootstrap-daemon/pvcbootstrapd/Daemon.py @@ -205,7 +205,7 @@ def read_config(): ) # Get the Notifications configuration - for key in ["enabled", "uri", "action", "icons", "body"]: + for key in ["enabled", "uri", "action", "icons", "body", "completed_triggerword"]: try: config[f"notifications_{key}"] = o_notifications[key] except Exception: diff --git a/bootstrap-daemon/pvcbootstrapd/lib/notifications.py b/bootstrap-daemon/pvcbootstrapd/lib/notifications.py index eb53b75..42b444f 100755 --- a/bootstrap-daemon/pvcbootstrapd/lib/notifications.py +++ b/bootstrap-daemon/pvcbootstrapd/lib/notifications.py @@ -38,6 +38,9 @@ def send_webhook(config, status, message): logger.debug(f"Sending notification to {config['notifications_uri']}") + if status == "completed" and config["notifications_completed_triggerword"]: + message = f"{message} {config['notifications_completed_triggerword']}" + # Get the body data body = config['notifications_body'] formatted_body = dict()