Add native Slack notification module#3
Open
hostarts wants to merge 1 commit into
Open
Conversation
Mirrors the existing email module so Slack delivery is wired into the same four call sites (cleanup_on_exit, handle_sigterm, replicate-only end, normal session end). This means failure-path notifications fire even when a run aborts before the normal end-of-main code path. The two notifiers are independent: SLACK_ENABLED, SLACK_ON_SUCCESS, and SLACK_ON_FAILURE let operators run Slack-only, email-only, or both. Session totals (VMs ok/failed/skipped/excluded, total bytes, duration) are pulled from the same sessions row the email module uses via sqlite_query_session_summary. curl is the only new dependency.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class Slack delivery alongside the existing email path. Until now, posting backup results to Slack required wrapping
vmbackup.shinExecStopPostor a cron post-hook, which only sees the systemd$SERVICE_RESULT/$EXIT_STATUSand has to re-derive session totals from the DB out-of-band. With this PR, Slack posts use the samesqlite_query_session_summaryrow the email module uses, fire from the same four call sites (so failure-path notifications still go out when a run aborts before normal end-of-main), and stay enabled/disabled independently of email.What changed
modules/slack_notification_module.sh(new):load_slack_config()+send_slack_notification()mirroringload_email_config()/send_backup_report(). Posts a coloured attachment with VM totals (ok / failed / skipped / excluded), total bytes, duration, and instance name. JSON is built inline; only runtime dependency iscurl.config/template/slack.conf(new):SLACK_ENABLED,SLACK_WEBHOOK_URL,SLACK_HOSTNAME,SLACK_TITLE_PREFIX,SLACK_ON_SUCCESS,SLACK_ON_FAILURE,SLACK_TIMEOUT. Independent flags so Slack-only / email-only / both are all valid combinations.vmbackup.sh: wired Slack into the same four sites as email —cleanup_on_exit(pre-flight aborts),handle_sigterm(systemd timeout / manual stop), the replicate-only mode end, and the normal session end inmain._SLACK_SENTguard prevents duplicate posts the same way_EMAIL_SENTdoes.CHANGELOG.md:[Unreleased]entry under### Added.Design notes
*_ON_SUCCESS/*_ON_FAILURE), same call sites, same data source. Operators who already understand the email config don't have to learn a new mental model.curl. Nojq. JSON is escaped with a small in-module helper (_slack_json_escape) so the module can drop into an existing AlmaLinux/Debian install with no extra packages.SLACK_ENABLED=\"no\"in the template; no behaviour change for existing installs.Test plan
bash -n vmbackup.sh+bash -n modules/slack_notification_module.shpass.load_slack_configround-trips a minimalslack.conf(smoke-tested locally)._slack_format_bytesproduces TiB/GiB/MiB/KiB/B with correct boundaries.vmbackup.shintegration sites match the four corresponding email sites (grep confirms 4×send_slack_notificationnext to 4×send_backup_report).🤖 Generated with Claude Code