aboutsummaryrefslogtreecommitdiffstats
path: root/molecule
diff options
context:
space:
mode:
authorColin Wilk <colin@wilk.cx>2026-06-23 13:21:35 +0200
committerColin Wilk <colin@wilk.cx>2026-06-23 13:21:35 +0200
commit0698339964e9289e9347834c91de25eb3ff8f963 (patch)
tree874c34a420de0ab6e947ebaae87408a80d1fba38 /molecule
parentdfeca121000dfc62f4337221ff35a48a4655580e (diff)
downloadansible-role-borgbackup-0698339964e9289e9347834c91de25eb3ff8f963.tar.gz
ansible-role-borgbackup-0698339964e9289e9347834c91de25eb3ff8f963.zip
test: add tests for systemd exist success status
Diffstat (limited to 'molecule')
-rw-r--r--molecule/default/converge.yml28
-rw-r--r--molecule/default/molecule.yml17
-rw-r--r--molecule/default/tests/test_systemd_success_exit_status.py12
3 files changed, 46 insertions, 11 deletions
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
index 7212eb2..995ccd0 100644
--- a/molecule/default/converge.yml
+++ b/molecule/default/converge.yml
@@ -1,11 +1,14 @@
---
- name: Converge
- hosts: borg-client
+ hosts:
+ - borg-client
+ - borg-client-success-exit-status
+ serial: 1
pre_tasks:
- # This would usually be set by the user globally on their ansible
- # repository and can be a security risk to do automatically. We will
- # however set the variable here in the pre_tasks since it is for testing.
+ # This would usually be set by the user globally on their ansible
+ # repository and can be a security risk to do automatically. We will
+ # however set the variable here in the pre_tasks since it is for testing.
- name: Set borg server openssh key variable
become: true
block:
@@ -14,7 +17,7 @@
name: sshd
state: started
become: true
- delegate_to: '{{ borg_server_host }}'
+ delegate_to: "{{ borg_server_host }}"
- name: Fetch ssh_key
ansible.builtin.command: >
@@ -27,14 +30,21 @@
- name: Set ssh_key
ansible.builtin.set_fact:
borg_server_host_ssh_key: '{{ borg_server_ssh_keyscan.stdout
- | split(" ")
- | reject("search", borg_server_host)
- | join(" ") }}'
+ | split(" ")
+ | reject("search", borg_server_host)
+ | join(" ") }}'
+
+ - name: Allow additional successful exit codes on alternate client
+ ansible.builtin.set_fact:
+ borg_backup_service_successful_exit_status:
+ - 1
+ - TEMPFAIL
+ when: inventory_hostname == 'borg-client-success-exit-status'
vars:
borg_server_host: borg-server
borg_server_user_home: /opt/borg
- borg_decryption_keys_yaml_path: '{{ playbook_dir }}/decryption_keys.yml'
+ borg_decryption_keys_yaml_path: "{{ playbook_dir }}/decryption_keys.yml"
borg_included_dirs:
- /etc
- /home
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index fc7a266..a64575b 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -10,7 +10,20 @@ driver:
platforms:
- name: borg-client
- image: ${MOLECULE_DISTRO_CLIENT:-debian:10}
+ image: ${MOLECULE_DISTRO_CLIENT:-debian:12}
+ dockerfile: Dockerfile.j2
+ pre_build_image: false
+ privileged: true
+ docker_networks:
+ - name: molecule-container-net
+ driver_options:
+ # Setting the mtu size due to issues with docker and VPN
+ com.docker.network.driver.mtu: 1420
+ networks:
+ - name: molecule-container-net
+
+ - name: borg-client-success-exit-status
+ image: ${MOLECULE_DISTRO_CLIENT:-debian:12}
dockerfile: Dockerfile.j2
pre_build_image: false
privileged: true
@@ -23,7 +36,7 @@ platforms:
- name: molecule-container-net
- name: borg-server
- image: ${MOLECULE_DISTRO_SERVER:-debian:10}
+ image: ${MOLECULE_DISTRO_SERVER:-debian:12}
dockerfile: Dockerfile.j2
pre_build_image: false
privileged: true
diff --git a/molecule/default/tests/test_systemd_success_exit_status.py b/molecule/default/tests/test_systemd_success_exit_status.py
new file mode 100644
index 0000000..8f2e242
--- /dev/null
+++ b/molecule/default/tests/test_systemd_success_exit_status.py
@@ -0,0 +1,12 @@
+testinfra_hosts = ["borg-client", "borg-client-success-exit-status"]
+
+
+def test_systemd_service_success_exit_status(host):
+ service = host.file("/etc/systemd/system/borg_backup@borg-server.service")
+
+ assert service.exists
+
+ if host.backend.get_hostname() == "borg-client-success-exit-status":
+ assert service.contains(r"^SuccessExitStatus=1 TEMPFAIL$")
+ else:
+ assert not service.contains(r"^SuccessExitStatus=")