diff --git a/README.md b/README.md index ab5fba9..84b5a13 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,26 @@ Works great with [BorgBase.com](https://www.borgbase.com) - Simple and Secure Ho keep_monthly: 6 ``` +## Example playbook with custom configuration options (borgmatic 1.8+) +**Note:** `borgmatic_custom_config` requires borgmatic 1.8.0 or later. + +``` +- hosts: all + roles: + - role: borgbase.ansible_role_borgbackup + borg_encryption_passphrase: CHANGEME + borg_repository: ssh://xxxxxx@xxxxxx.repo.borgbase.com/./repo + borg_source_directories: + - /var/www + borgmatic_custom_config: + uptime_kuma: + push_url: https://uptime.kuma.example.com/abcd1234 + ntfy: + topic: backups + server: https://ntfy.sh + output_verbosity: 1 +``` ## Installation @@ -121,6 +140,7 @@ $ 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_custom_config`: Custom YAML configuration (as a dictionary) to add to the borgmatic config file. Allows adding any additional borgmatic options not covered by other variables. **Requires borgmatic 1.8.0 or later.** See example above. - `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..33eb5f2 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -46,6 +46,7 @@ borgmatic_store_ctime: true borgmatic_relocated_repo_access_is_ok: false borgmatic_unknown_unencrypted_repo_access_is_ok: false borgmatic_version: ">=1.7.11" +borgmatic_custom_config: {} borg_venv_path: "/opt/borgmatic" borg_user: "root" diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index eaa99f5..6851fc5 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -211,6 +211,10 @@ argument_specs: type: str required: false description: Borgmatic version to install. Defaults to 'latest' + borgmatic_custom_config: + type: dict + required: false + description: Custom YAML configuration to add to the borgmatic config file. Allows adding any additional borgmatic options not covered by other variables. Requires borgmatic 1.8.0 or later. borg_ssh_key_type: type: str required: false diff --git a/tasks/05_configure.yml b/tasks/05_configure.yml index d4a6254..b90b165 100644 --- a/tasks/05_configure.yml +++ b/tasks/05_configure.yml @@ -12,6 +12,12 @@ ansible.builtin.set_fact: borgmatic_version: "{{ borgmatic_version_output.stdout.split()[0] }}" + - name: Ensure custom config is only used with borgmatic 1.8+ + ansible.builtin.assert: + that: + - borgmatic_custom_config is not defined or borgmatic_custom_config | length == 0 or borgmatic_version is version('1.8.0', '>=') + msg: "borgmatic_custom_config requires borgmatic 1.8.0 or later. Detected version: {{ borgmatic_version }}" + - name: Ensure /etc/borgmatic exists ansible.builtin.file: path: /etc/borgmatic diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index 65f96aa..d15e6d8 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -197,3 +197,9 @@ check_last: {{ borgmatic_check_last }} {{ hook }}: {{ borgmatic_hooks[hook] | to_nice_yaml(indent=4) | indent(4, first=true) }} {% endfor %} + +{% if borgmatic_custom_config is defined and borgmatic_custom_config %} +# Custom configuration +{{ borgmatic_custom_config | to_nice_yaml(indent=4) }} +{% endif %} +