From 50a2795c3a6c72203262400db5029f5afdf1d49c Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Fri, 3 Nov 2023 19:45:20 +0100 Subject: Migrate role from cron to systemd Systemd gives us the ability to monitor backup job status using existing monitoring solutions (node exporter) and allows us greater control over the scheduling of the backup jobs. This introduces a breaking change that requires users to manually remove the old repositories from the clients and redeploying them with the role. You will have to remove the Cron job that was created by the Ansible script, everything else will be overwritten with a run from the newer version. - name: Remove backup cron jobs ansible.builtin.cron: name: BORG (Application level backups) state: absent become: true - name: Remove env for backup cron job ansible.builtin.cron: name: BORG_PASSPHRASE env: true state: absent become: true Performing manual migrations on the Borg server is not required. We now additionally support multiple Borg repositories per client host using the `borg_backup_argument` variable. Signed-off-by: Colin Wilk --- molecule/default/Dockerfile.j2 | 3 ++- molecule/default/converge.yml | 10 +++++++--- molecule/default/molecule.yml | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'molecule') diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 index 091ef00..cc459e3 100644 --- a/molecule/default/Dockerfile.j2 +++ b/molecule/default/Dockerfile.j2 @@ -6,10 +6,11 @@ RUN apt-get update \ sudo wget \ python3-pip python3-dev python3-setuptools python3-wheel python3-apt \ sed ssh openssh-server \ + systemd systemd-sysv dbus dbus-user-session \ && rm -rf /var/lib/apt/lists/* \ && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ && apt-get clean RUN mkdir /run/sshd -ENTRYPOINT ["bash", "-c", "/usr/sbin/sshd && sleep infinity"] +ENTRYPOINT ["/sbin/init"] diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 17b5f0e..7212eb2 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -9,6 +9,13 @@ - name: Set borg server openssh key variable become: true block: + - name: Start ssh + ansible.builtin.systemd: + name: sshd + state: started + become: true + delegate_to: '{{ borg_server_host }}' + - name: Fetch ssh_key ansible.builtin.command: > ssh-keyscan -t rsa @@ -35,9 +42,6 @@ - /opt - /var - /reee reeee - borg_cron_time: - minute: '*' - hour: '*' roles: - role: kliwniloc.borgbackup diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 3c0dfef..fc7a266 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -13,6 +13,7 @@ platforms: image: ${MOLECULE_DISTRO_CLIENT:-debian:10} dockerfile: Dockerfile.j2 pre_build_image: false + privileged: true docker_networks: - name: molecule-container-net driver_options: @@ -25,6 +26,7 @@ platforms: image: ${MOLECULE_DISTRO_SERVER:-debian:10} dockerfile: Dockerfile.j2 pre_build_image: false + privileged: true networks: - name: molecule-container-net -- cgit v1.2.3