mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-04-29 12:12:11 +00:00
server: notifications: send acme notifications via notification system
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> Tested-by: Gabriel Goller <g.goller@proxmox.com> Reviewed-by: Gabriel Goller <g.goller@proxmox.com> Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
823314c7f4
commit
1d2069d158
2
debian/proxmox-backup-server.install
vendored
2
debian/proxmox-backup-server.install
vendored
@ -41,6 +41,8 @@ usr/share/zsh/vendor-completions/_pmtx
|
|||||||
usr/share/zsh/vendor-completions/_proxmox-backup-debug
|
usr/share/zsh/vendor-completions/_proxmox-backup-debug
|
||||||
usr/share/zsh/vendor-completions/_proxmox-backup-manager
|
usr/share/zsh/vendor-completions/_proxmox-backup-manager
|
||||||
usr/share/zsh/vendor-completions/_proxmox-tape
|
usr/share/zsh/vendor-completions/_proxmox-tape
|
||||||
|
usr/share/proxmox-backup/templates/default/acme-err-body.txt.hbs
|
||||||
|
usr/share/proxmox-backup/templates/default/acme-err-subject.txt.hbs
|
||||||
usr/share/proxmox-backup/templates/default/gc-err-body.txt.hbs
|
usr/share/proxmox-backup/templates/default/gc-err-body.txt.hbs
|
||||||
usr/share/proxmox-backup/templates/default/gc-ok-body.txt.hbs
|
usr/share/proxmox-backup/templates/default/gc-ok-body.txt.hbs
|
||||||
usr/share/proxmox-backup/templates/default/gc-err-subject.txt.hbs
|
usr/share/proxmox-backup/templates/default/gc-err-subject.txt.hbs
|
||||||
|
@ -86,18 +86,6 @@ Please visit the web interface for further details:
|
|||||||
|
|
||||||
"###;
|
"###;
|
||||||
|
|
||||||
const ACME_CERTIFICATE_ERR_RENEWAL: &str = r###"
|
|
||||||
|
|
||||||
Proxmox Backup Server was not able to renew a TLS certificate.
|
|
||||||
|
|
||||||
Error: {{error}}
|
|
||||||
|
|
||||||
Please visit the web interface for further details:
|
|
||||||
|
|
||||||
<https://{{fqdn}}:{{port}}/#pbsCertificateConfiguration>
|
|
||||||
|
|
||||||
"###;
|
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
|
|
||||||
static ref HANDLEBARS: Handlebars<'static> = {
|
static ref HANDLEBARS: Handlebars<'static> = {
|
||||||
@ -110,8 +98,6 @@ lazy_static::lazy_static! {
|
|||||||
hb.register_template_string("tape_backup_ok_template", TAPE_BACKUP_OK_TEMPLATE)?;
|
hb.register_template_string("tape_backup_ok_template", TAPE_BACKUP_OK_TEMPLATE)?;
|
||||||
hb.register_template_string("tape_backup_err_template", TAPE_BACKUP_ERR_TEMPLATE)?;
|
hb.register_template_string("tape_backup_err_template", TAPE_BACKUP_ERR_TEMPLATE)?;
|
||||||
|
|
||||||
hb.register_template_string("certificate_renewal_err_template", ACME_CERTIFICATE_ERR_RENEWAL)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -598,23 +584,22 @@ pub fn send_certificate_renewal_mail(result: &Result<(), Error>) -> Result<(), E
|
|||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(email) = lookup_user_email(Userid::root_userid()) {
|
let (fqdn, port) = get_server_url();
|
||||||
let (fqdn, port) = get_server_url();
|
|
||||||
|
|
||||||
let text = HANDLEBARS.render(
|
let data = json!({
|
||||||
"certificate_renewal_err_template",
|
"fqdn": fqdn,
|
||||||
&json!({
|
"port": port,
|
||||||
"fqdn": fqdn,
|
"error": error,
|
||||||
"port": port,
|
});
|
||||||
"error": error,
|
|
||||||
}),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let subject = "Could not renew certificate";
|
let metadata = HashMap::from([
|
||||||
|
("hostname".into(), proxmox_sys::nodename().into()),
|
||||||
|
("type".into(), "acme".into()),
|
||||||
|
]);
|
||||||
|
|
||||||
send_job_status_mail(&email, subject, &text)?;
|
let notification = Notification::from_template(Severity::Info, "acme-err", data, metadata);
|
||||||
}
|
|
||||||
|
|
||||||
|
send_notification(notification)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,6 +658,4 @@ pub fn lookup_datastore_notify_settings(
|
|||||||
fn test_template_register() {
|
fn test_template_register() {
|
||||||
assert!(HANDLEBARS.has_template("tape_backup_ok_template"));
|
assert!(HANDLEBARS.has_template("tape_backup_ok_template"));
|
||||||
assert!(HANDLEBARS.has_template("tape_backup_err_template"));
|
assert!(HANDLEBARS.has_template("tape_backup_err_template"));
|
||||||
|
|
||||||
assert!(HANDLEBARS.has_template("certificate_renewal_err_template"));
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
include ../defines.mk
|
include ../defines.mk
|
||||||
|
|
||||||
NOTIFICATION_TEMPLATES= \
|
NOTIFICATION_TEMPLATES= \
|
||||||
default/gc-err-body.txt.hbs \
|
default/acme-err-body.txt.hbs \
|
||||||
default/gc-ok-body.txt.hbs \
|
default/acme-err-subject.txt.hbs \
|
||||||
default/gc-err-subject.txt.hbs \
|
default/gc-err-body.txt.hbs \
|
||||||
default/gc-ok-subject.txt.hbs \
|
default/gc-ok-body.txt.hbs \
|
||||||
default/package-updates-body.txt.hbs \
|
default/gc-err-subject.txt.hbs \
|
||||||
default/package-updates-subject.txt.hbs \
|
default/gc-ok-subject.txt.hbs \
|
||||||
|
default/package-updates-body.txt.hbs \
|
||||||
|
default/package-updates-subject.txt.hbs \
|
||||||
default/prune-err-body.txt.hbs \
|
default/prune-err-body.txt.hbs \
|
||||||
default/prune-ok-body.txt.hbs \
|
default/prune-ok-body.txt.hbs \
|
||||||
default/prune-err-subject.txt.hbs \
|
default/prune-err-subject.txt.hbs \
|
||||||
@ -14,10 +16,10 @@ NOTIFICATION_TEMPLATES= \
|
|||||||
default/sync-err-body.txt.hbs \
|
default/sync-err-body.txt.hbs \
|
||||||
default/sync-ok-body.txt.hbs \
|
default/sync-ok-body.txt.hbs \
|
||||||
default/sync-err-subject.txt.hbs \
|
default/sync-err-subject.txt.hbs \
|
||||||
default/sync-ok-subject.txt.hbs \
|
default/sync-ok-subject.txt.hbs \
|
||||||
default/test-body.txt.hbs \
|
default/test-body.txt.hbs \
|
||||||
default/test-body.html.hbs \
|
default/test-body.html.hbs \
|
||||||
default/test-subject.txt.hbs \
|
default/test-subject.txt.hbs \
|
||||||
default/verify-err-body.txt.hbs \
|
default/verify-err-body.txt.hbs \
|
||||||
default/verify-ok-body.txt.hbs \
|
default/verify-ok-body.txt.hbs \
|
||||||
default/verify-err-subject.txt.hbs \
|
default/verify-err-subject.txt.hbs \
|
||||||
|
7
templates/default/acme-err-body.txt.hbs
Normal file
7
templates/default/acme-err-body.txt.hbs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Proxmox Backup Server was not able to renew a TLS certificate.
|
||||||
|
|
||||||
|
Error: {{error}}
|
||||||
|
|
||||||
|
Please visit the web interface for further details:
|
||||||
|
|
||||||
|
<https://{{fqdn}}:{{port}}/#pbsCertificateConfiguration>
|
1
templates/default/acme-err-subject.txt.hbs
Normal file
1
templates/default/acme-err-subject.txt.hbs
Normal file
@ -0,0 +1 @@
|
|||||||
|
Could not renew certificate
|
Loading…
Reference in New Issue
Block a user