From 2630e4842df64b27106cfae1b1178c64852cec2e Mon Sep 17 00:00:00 2001 From: borismw <52957119+borismw@users.noreply.github.com> Date: Mon, 26 Oct 2026 23:47:45 +0100 Subject: [PATCH 1/3] ADD:support patterns and patterns_from --- meta/argument_specs.yml | 10 ++++++++++ molecule/default/Dockerfile.j2 | 2 ++ molecule/default/converge.yml | 4 ++++ molecule/default/verify.yml | 2 ++ tasks/configure.yml | 6 ++++++ vars/main.yml | 2 ++ 6 files changed, 26 insertions(+) diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index bc47002..c5e92aa 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -166,6 +166,16 @@ argument_specs: elements: str required: false description: Files containing Borg exclude patterns. + patterns: + type: list + elements: str + required: false + description: Borg include patterns. + patterns_from: + type: list + elements: str + required: false + description: Files containing Borg include patterns. exclude_caches: type: bool required: false diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 index 1bc3eb8..17d115f 100644 --- a/molecule/default/Dockerfile.j2 +++ b/molecule/default/Dockerfile.j2 @@ -14,6 +14,8 @@ ENV {{ var }} {{ value }} {% endfor %} {% endif %} +RUN mkdir -p /tmp && echo "R /etc" > /tmp/patterns_from.txt + RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 python3-pip sudo bash ca-certificates curl iproute2 python3-apt aptitude && apt-get clean; \ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash ca-certificates curl iproute && dnf clean all; \ elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index e09d050..60b4348 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -66,6 +66,10 @@ - /tmp/borgbackup-source exclude_patterns: - /tmp/borgbackup-source/excluded + patterns: + - R /etc/sudoers.d + patterns_from: + - /tmp/patterns_from.txt retention: keep_hourly: 3 keep_daily: 7 diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index ef4e6d4..a2c7f3a 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -35,6 +35,8 @@ - "borgbackup_rendered_config_data.repositories[0].path == '/tmp/borgbackup-molecule-repo'" - "borgbackup_rendered_config_data.source_directories == ['/tmp/borgbackup-source']" - "borgbackup_rendered_config_data.exclude_patterns == ['/tmp/borgbackup-source/excluded']" + - "borgbackup_rendered_config_data.patterns == ['R /etc/sudoers.d']" + - "borgbackup_rendered_config_data.patterns_from == ['/tmp/patterns_from.txt']" - "borgbackup_rendered_config_data.encryption_passphrase == 'CHANGEME'" - "borgbackup_rendered_config_data.exclude_caches | bool" - "borgbackup_rendered_config_data.exclude_if_present == ['.nobackup']" diff --git a/tasks/configure.yml b/tasks/configure.yml index 4127044..8a4acbf 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -73,6 +73,12 @@ - when: "{{ _borgbackup_config.exclude_from | length > 0 }}" value: exclude_from: "{{ _borgbackup_config.exclude_from }}" + - when: "{{ _borgbackup_config.patterns | length > 0 }}" + value: + patterns: "{{ _borgbackup_config.patterns }}" + - when: "{{ _borgbackup_config.patterns_from | length > 0 }}" + value: + patterns_from: "{{ _borgbackup_config.patterns_from }}" - when: "{{ _borgbackup_config.remote_path | length > 0 }}" value: remote_path: "{{ _borgbackup_config.remote_path }}" diff --git a/vars/main.yml b/vars/main.yml index 86b7c77..a13ae67 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -41,6 +41,8 @@ _borgbackup_config_defaults: exclude_caches: true exclude_if_present: - .nobackup + patterns: [] + patterns_from: [] encryption_passphrase: "" encryption_passcommand: "" remote_path: "" From 7e2bfe84550f2b995e25374fb683121c547e0602 Mon Sep 17 00:00:00 2001 From: borismw <52957119+borismw@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:56:15 +0100 Subject: [PATCH 2/3] CHG:experiment with debug statements --- tasks/assert.yml | 12 ++++++++++++ tasks/user.yml | 1 + 2 files changed, 13 insertions(+) diff --git a/tasks/assert.yml b/tasks/assert.yml index 5ac5c2e..5471e2b 100644 --- a/tasks/assert.yml +++ b/tasks/assert.yml @@ -21,6 +21,18 @@ _borgbackup_config: "{{ _borgbackup_config_defaults | combine(borgbackup_config | default({}), recursive=true) }}" _borgbackup_timer: "{{ _borgbackup_timer_defaults | combine(borgbackup_timer | default({}), recursive=true) }}" +- name: Print ssh_defaults + ansible.builtin.debug: + msg: "Defaults: {{ _borgbackup_ssh_defaults }}" + +- name: Print ssh_config + ansible.builtin.debug: + msg: "Config: {{ borgbackup_ssh }}" + +- name: Print ssh_combined + ansible.builtin.debug: + msg: "Combined: {{ _borgbackup_ssh }}" + - name: Normalize borgbackup install package versions ansible.builtin.set_fact: _borgbackup_install: >- diff --git a/tasks/user.yml b/tasks/user.yml index 620bc38..150bd39 100644 --- a/tasks/user.yml +++ b/tasks/user.yml @@ -8,6 +8,7 @@ - _borgbackup_user.create | bool - name: Create backup user + become: true ansible.builtin.user: name: "{{ _borgbackup_user.name }}" shell: "{{ _borgbackup_user.shell }}" From 30ad0903e3d3daa162f5276a5a10da7c5c638523 Mon Sep 17 00:00:00 2001 From: borismw <52957119+borismw@users.noreply.github.com> Date: Tue, 27 Oct 2026 23:09:57 +0100 Subject: [PATCH 3/3] experiment with | default --- tasks/configure.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 8a4acbf..17416da 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -102,7 +102,7 @@ ssh_command: "{{ _borgbackup_ssh.command }}" - when: "{{ _borgbackup_ssh.create | bool and _borgbackup_ssh.command | length == 0 and _borgbackup_ssh_key_name != 'id_' ~ _borgbackup_ssh.key_type }}" value: - ssh_command: "ssh -i {{ _borgbackup_ssh_key_path }}" + ssh_command: "ssh -i {{ _borgbackup_ssh_key_path | default }}" when: item.when | bool loop_control: label: "{{ item.value.keys() | first }}"