Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
borgmatic_hooks:
before_backup:
- echo "`date` - Starting backup."
healthchecks: https://hc-ping.com/12345678-1234-1234-1234-123456789012
postgresql_databases:
- name: users
hostname: database1.example.org
Expand Down
17 changes: 17 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@
- name: Ensure produced YAML is valid
command: |
yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" /etc/borgmatic/config.yaml

- name: Read borgmatic config
ansible.builtin.slurp:
src: /etc/borgmatic/config.yaml
register: borgmatic_config

- name: Parse borgmatic config as YAML
ansible.builtin.set_fact:
borgmatic_config_parsed: "{{ borgmatic_config.content | b64decode | from_yaml }}"

- name: Verify healthchecks URL is not corrupted by to_nice_yaml scalar bug
ansible.builtin.assert:
that:
- >-
'...' not in (borgmatic_config_parsed.healthchecks |
default(borgmatic_config_parsed.hooks.healthchecks | default('')))
fail_msg: "healthchecks URL corrupted by to_nice_yaml scalar bug (contains '...')"
6 changes: 1 addition & 5 deletions templates/config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,9 @@ check_last: {{ borgmatic_check_last }}
# IMPORTANT: All provided commands and scripts are executed with user permissions of borgmatic.
# Do not forget to set secure permissions on this file as well as on any script listed (chmod 0700) to
# prevent potential shell injection or privilege escalation.
{% for hook in borgmatic_hooks %}
{{ hook }}:
{{ borgmatic_hooks[hook] | to_nice_yaml(indent=4) | indent(4, first=true) }}
{% endfor %}
{{ borgmatic_hooks | to_nice_yaml(indent=4, width=1000) }}

{% if borgmatic_custom_config is defined and borgmatic_custom_config %}
# Custom configuration
{{ borgmatic_custom_config | to_nice_yaml(indent=4) }}
{% endif %}

5 changes: 1 addition & 4 deletions templates/config_1.7.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,4 @@ consistency:
# Do not forget to set secure permissions on this file as well as on any script listed (chmod 0700) to
# prevent potential shell injection or privilege escalation.
hooks:
{% for hook in borgmatic_hooks %}
{{ hook }}:
{{ borgmatic_hooks[hook] | to_nice_yaml(indent=4) | indent(8, first=true) }}
{% endfor %}
{{ borgmatic_hooks | to_nice_yaml(indent=4, width=1000) | indent(4) }}