Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.yaml syntax deprecated #145

Open
sinux-l5d opened this issue Feb 9, 2024 · 1 comment
Open

config.yaml syntax deprecated #145

sinux-l5d opened this issue Feb 9, 2024 · 1 comment

Comments

@sinux-l5d
Copy link

Hello,

Using this module I run into a deprecated warning when running borgmatic:

summary:
/etc/borgmatic/config.yaml: Configuration sections (like location:, storage:, retention:, consistency:, and hooks:) are deprecated and support will be removed from a future release. To prepare for this, move your options out of sections to the global scope.
/etc/borgmatic/config.yaml: The exclude_if_present option now expects a list value. String values for this option are deprecated and support will be removed from a future release.

The fix is quite simple, but needs some adapting for the repositories list: it now expects objects with the path and label keys.

So far, I came up with this :

#jinja2: lstrip_blocks: "True", trim_blocks: "True"
---
{# List of... #}
repositories:
{% if borg_repository is iterable and (borg_repository is not string and borg_repository is not mapping) %}
  {% for repo in borg_repository %}
  {# ...mappings #}
  {% if repo is mapping and "path" in repo and "label" in repo %}
    {{ [repo] | to_nice_yaml(indent=2) | trim | indent(4) }}
  {# ...strings (legacy) #}
  {% elif repo is string %}
    - path: {{ repo }}
      label: {{ repo }}
  {% endif %}
  {% endfor %}
{# Mapping with path and label key #}
{% elif borg_repository is defined and borg_repository is mapping and "path" in borg_repository and "label" in borg_repository %}
    - path: {{ borg_repository.path }}
      label: {{ borg_repository.label }}
{# String (legacy) #}
{% elif borg_repository is defined and borg_repository is string %}
    - path: {{ borg_repository }}
      label: {{ borg_repository }}
{% endif %}

But it's not perfect, if the label is not provided, it will use the repo path.

This template is compatible with the following:

- import_role:  borgbase.ansible_role_borgbackup
  vars:
    borg_repository: "ssh://[email protected]/./repo"
    [...]
- import_role:  borgbase.ansible_role_borgbackup
  vars:
    borg_repository: 
        - "ssh://[email protected]/./repo"
    [...]
- import_role:  borgbase.ansible_role_borgbackup
  vars:
    borg_repository:
        - path: "ssh://[email protected]/./repo"
          label: default
    [...]
- import_role:  borgbase.ansible_role_borgbackup
  vars:
    borg_repository:
        path: "ssh://[email protected]/./repo"
        label: default
    [...]

And will render into something like:

repositories:
    - path: path_here
      label: label_or_path_here

Full commit : sinux-l5d@7fc5fe2

@artybdrlt
Copy link

I second that comment. I also came across this warning message this morning with my latest borg-related project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants