Skip to content
Closed
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
10 changes: 10 additions & 0 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
4 changes: 4 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
Expand Down
12 changes: 12 additions & 0 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
8 changes: 7 additions & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -96,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 }}"
Expand Down
1 change: 1 addition & 0 deletions tasks/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ _borgbackup_config_defaults:
exclude_caches: true
exclude_if_present:
- .nobackup
patterns: []
patterns_from: []
encryption_passphrase: ""
encryption_passcommand: ""
remote_path: ""
Expand Down