diff options
Diffstat (limited to 'ansible/roles/borg-job')
-rw-r--r-- | ansible/roles/borg-job/defaults/main.yml | 6 | ||||
-rw-r--r-- | ansible/roles/borg-job/handlers/main.yml | 8 | ||||
-rw-r--r-- | ansible/roles/borg-job/tasks/main.yml | 60 |
3 files changed, 74 insertions, 0 deletions
diff --git a/ansible/roles/borg-job/defaults/main.yml b/ansible/roles/borg-job/defaults/main.yml new file mode 100644 index 0000000..b5f3cbc --- /dev/null +++ b/ansible/roles/borg-job/defaults/main.yml @@ -0,0 +1,6 @@ +borg_job__on_calendar: daily +borg_job__default_excludes: + - /proc + - /dev + - /sys + - /run diff --git a/ansible/roles/borg-job/handlers/main.yml b/ansible/roles/borg-job/handlers/main.yml new file mode 100644 index 0000000..76e08ab --- /dev/null +++ b/ansible/roles/borg-job/handlers/main.yml @@ -0,0 +1,8 @@ +- name: systemctl daemon-reload + systemd: + daemon_reload: true + +- name: "service start tergum@{{ borg_job__name }}.timer" + service: + name: "tergum@{{ borg_job__name }}.timer" + state: restarted diff --git a/ansible/roles/borg-job/tasks/main.yml b/ansible/roles/borg-job/tasks/main.yml new file mode 100644 index 0000000..10076d6 --- /dev/null +++ b/ansible/roles/borg-job/tasks/main.yml @@ -0,0 +1,60 @@ +- name: Install packages + tags: packages + apt: + name: + - borgbackup + install_recommends: no + +- name: "mkdir /etc/tergum/jobs/{{ borg_job__name }}" + file: + path: "/etc/tergum/jobs/{{ borg_job__name }}" + state: directory + +- name: "/etc/tergum/jobs/{{ borg_job__name }}/env" + copy: + dest: "/etc/tergum/jobs/{{ borg_job__name }}/env" + content: | + BORG_REPO={{ borg_job__username }}@{{ borg_job__target }}:{{ ansible_hostname }}/{{ borg_job__name }} + BORG_RSH=ssh -i /etc/tergum/ssh-key + BORG_PASSPHRASE={{ borg__passphrases[ansible_hostname][borg_job__name] }} + +# BORG_KEYS_DIR +# BORG_SECURITY_DIR +# BORG_CACHE_DIR + +- name: "/etc/tergum/jobs/{{ borg_job__name }}/patterns" + copy: + dest: "/etc/tergum/jobs/{{ borg_job__name }}/patterns" + content: "{{ borg_job__settings.patterns }}" + +- name: "/etc/tergum/jobs/{{ borg_job__name }}/excludes" + vars: + excludes: "{{ borg_job__settings.excludes if borg_job__settings.excludes is defined else [] }}" + copy: + dest: "/etc/tergum/jobs/{{ borg_job__name }}/excludes" + content: | + {% for item in excludes %} + {{ item }} + {% endfor %} + {% for item in borg_job__default_excludes %} + {{ item }} + {% endfor %} + +- file: + path: "/etc/systemd/system/tergum@{{ borg_job__name }}.timer.d" + state: directory + +- copy: + dest: "/etc/systemd/system/tergum@{{ borg_job__name }}.timer.d/override.conf" + content: | + [Timer] + OnCalendar={{ borg_job__settings.on_calendar if borg_job__settings.on_calendar is defined else borg_job__on_calendar }} + notify: + - systemctl daemon-reload + +- meta: flush_handlers + +- systemd: + name: "tergum@{{ borg_job__name }}.timer" + enabled: yes + state: started |