From bebe44d0805211d5d6d347c5e8af418f98b035e9 Mon Sep 17 00:00:00 2001 From: Manu <3916435+m3nu@users.noreply.github.com> Date: Wed, 17 Feb 2021 10:16:34 +0800 Subject: [PATCH] Rebased: cron name setable by @debauer (#59) See #51 --- defaults/main.yml | 1 + molecule/default/molecule.yml | 6 ++---- tasks/main.yml | 16 ++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 949e9ce..c3969b9 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -37,6 +37,7 @@ bb_quota_size: 0 bb_alertdays: 0 bb_repo_name: "{{ inventory_hostname }}" bb_sshkey: "{{ root_user['ssh_public_key'] }}" +borgmatic_cron_name: borgmatic borgmatic_cron_hour: "{{ 6 | random(seed=inventory_hostname) }}" borgmatic_cron_minute: "{{ 59 | random(seed=inventory_hostname) }}" borgmatic_cron_checks_day: "{{ range(1, 28) | random(seed=inventory_hostname) }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 7b42d48..a4079f9 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -16,10 +16,8 @@ platforms: image: debian:oldstable - name: debian-stable image: debian:stable - - name: ubuntu-xenial - image: ubuntu:xenial - # - name: ubuntu-trusty # Python too old - # image: ubuntu:trusty + - name: ubuntu-bionic + image: ubuntu:bionic - name: ubuntu-latest image: ubuntu:latest provisioner: diff --git a/tasks/main.yml b/tasks/main.yml index 22cf6c2..293279a 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -87,20 +87,20 @@ block: - name: Add cron job for regular create and prune cron: - name: "borgmatic" + name: "{{ borgmatic_cron_name }}" hour: "{{ borgmatic_cron_hour }}" minute: "{{ borgmatic_cron_minute }}" user: "root" - cron_file: borgmatic + cron_file: "{{ borgmatic_cron_name }}" job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune" - name: Add cron job for infrequent checks cron: - name: "borgmatic-check" + name: "{{ borgmatic_cron_name }}-check" day: "{{ borgmatic_cron_checks_day }}" hour: "{{ borgmatic_cron_checks_hour }}" minute: "{{ borgmatic_cron_checks_minute }}" user: "root" - cron_file: borgmatic + cron_file: "{{ borgmatic_cron_name }}" job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --check" when: borgmatic_large_repo @@ -108,22 +108,22 @@ block: - name: Add cron job for create, check and prune cron: - name: "borgmatic" + name: "{{ borgmatic_cron_name }}" hour: "{{ borgmatic_cron_hour }}" minute: "{{ borgmatic_cron_minute }}" user: "root" - cron_file: borgmatic + cron_file: "{{ borgmatic_cron_name }}" job: "/usr/local/bin/borgmatic" - name: Ensure separate check cron job is absent cron: - name: "borgmatic-check" + name: "{{ borgmatic_cron_name }}-check" state: absent when: not borgmatic_large_repo - name: Set PATH for borgmatic cron job. cron: user: "root" - cron_file: borgmatic + cron_file: "{{ borgmatic_cron_name }}" name: PATH env: yes value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin