diff --git a/EXAMPLES.md b/EXAMPLES.md index 5957818..2b4f410 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -16,6 +16,25 @@ borg_group: backupuser ``` +## Using Uptime Kuma for Backup Monitoring + +``` +- hosts: webservers + roles: + - role: borgbase.ansible_role_borgbackup + borg_encryption_passphrase: CHANGEME + borg_repository: ssh://m5vz9gp4@m5vz9gp4.repo.borgbase.com/./repo + borgmatic_timer: systemd + borg_source_directories: + - /var/www + borgmatic_uptime_kuma_push_url: "https://example.uptime.kuma/api/push/abcd1234" + borgmatic_uptime_kuma_states: + - start + - finish + - fail + borgmatic_uptime_kuma_verify_tls: true +``` + ## Use service user and copy SSH key to target server Installs and configures the Borgmatic client and also initializes the repo on the diff --git a/README.md b/README.md index ab5fba9..8995707 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,9 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/ansibl - `borgmatic_store_atime`: Store atime into archive. Defaults to `true` - `borgmatic_store_ctime`: Store ctime into archive. Defaults to `true` - `borgmatic_version`: Force a specific borgmatic version to be installed +- `borgmatic_uptime_kuma_push_url`: Uptime Kuma push URL for monitoring (without query string). See [Uptime Kuma documentation](https://torsion.org/borgmatic/reference/configuration/monitoring/uptime-kuma/) for more. Example: `https://example.uptime.kuma/api/push/abcd1234` +- `borgmatic_uptime_kuma_states`: List of monitoring states to push for. Defaults to `['start', 'finish', 'fail']`. Valid values are: `start`, `finish`, and `fail`. +- `borgmatic_uptime_kuma_verify_tls`: Verify the TLS certificate of the push URL host. Defaults to `true` - `borg_user`: Name of the User to create Backups (service account) - `borg_group`: Name of the Group to create Backups (service account) diff --git a/defaults/main.yml b/defaults/main.yml index 4d928a4..35e7bd1 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -47,6 +47,14 @@ borgmatic_relocated_repo_access_is_ok: false borgmatic_unknown_unencrypted_repo_access_is_ok: false borgmatic_version: ">=1.7.11" +# Uptime Kuma monitoring configuration +# borgmatic_uptime_kuma_push_url: "https://example.uptime.kuma/api/push/abcd1234" +borgmatic_uptime_kuma_states: + - start + - finish + - fail +borgmatic_uptime_kuma_verify_tls: true + borg_venv_path: "/opt/borgmatic" borg_user: "root" borg_group: "root" diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index eaa99f5..aabda3e 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -223,3 +223,21 @@ argument_specs: type: str required: false description: Comment added to the SSH public key. + borgmatic_uptime_kuma_push_url: + type: str + required: false + description: | + Uptime Kuma push URL for monitoring (without query string). + Example: https://example.uptime.kuma/api/push/abcd1234 + borgmatic_uptime_kuma_states: + type: list + required: false + default: ['start', 'finish', 'fail'] + description: | + List of one or more monitoring states to push for: "start", "finish", and/or "fail". + Defaults to pushing for all states. + borgmatic_uptime_kuma_verify_tls: + type: bool + required: false + default: true + description: Verify the TLS certificate of the push URL host. Defaults to true. diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index 65f96aa..703d273 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -197,3 +197,30 @@ check_last: {{ borgmatic_check_last }} {{ hook }}: {{ borgmatic_hooks[hook] | to_nice_yaml(indent=4) | indent(4, first=true) }} {% endfor %} + +{% if borgmatic_uptime_kuma_push_url is defined and borgmatic_uptime_kuma_push_url %} +# Configuration for a monitoring integration with Uptime Kuma using +# the Push monitor type. +# See more information here: https://uptime.kuma.pet +uptime_kuma: + # Uptime Kuma push URL without query string (do not include the + # question mark or anything after it). + push_url: {{ borgmatic_uptime_kuma_push_url }} + +{% if borgmatic_uptime_kuma_states is defined and borgmatic_uptime_kuma_states | length > 0 %} + # List of one or more monitoring states to push for: "start", + # "finish", and/or "fail". Defaults to pushing for all + # states. + states: +{% for state in borgmatic_uptime_kuma_states %} + - {{ state }} +{% endfor %} +{% endif %} + +{% if borgmatic_uptime_kuma_verify_tls is defined %} + # Verify the TLS certificate of the push URL host. Defaults to + # true. + verify_tls: {{ borgmatic_uptime_kuma_verify_tls | lower }} +{% endif %} +{% endif %} +