aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/borg-job/tasks
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-15 13:58:42 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-08-08 09:03:00 +0200
commit030305fc22b16851935de4dc52f912c550bdbd09 (patch)
tree3153888a7d1b63468194f0e8334ffbf4ef63dbea /ansible/roles/borg-job/tasks
parent4bd33c6a46f57f8a830042795cfaa68ef91963a9 (diff)
downloadinfra-030305fc22b16851935de4dc52f912c550bdbd09.tar.gz
infra-030305fc22b16851935de4dc52f912c550bdbd09.tar.bz2
infra-030305fc22b16851935de4dc52f912c550bdbd09.tar.xz
infra-030305fc22b16851935de4dc52f912c550bdbd09.zip
o New borg.
Diffstat (limited to 'ansible/roles/borg-job/tasks')
-rw-r--r--ansible/roles/borg-job/tasks/main.yml60
1 files changed, 60 insertions, 0 deletions
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