aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2019-07-15 20:40:00 +0200
committerJulien Dessaux2019-07-15 20:40:00 +0200
commitdfc762b0058cf4a9ef7337c7a0883e2c5a5c3c9d (patch)
tree6f468503635e8e6be3afbaad15d5cd163a1a96b3
parentAdded borg backup role (diff)
downloadborg-ansible-role-dfc762b0058cf4a9ef7337c7a0883e2c5a5c3c9d.tar.gz
borg-ansible-role-dfc762b0058cf4a9ef7337c7a0883e2c5a5c3c9d.tar.bz2
borg-ansible-role-dfc762b0058cf4a9ef7337c7a0883e2c5a5c3c9d.zip
Ansible best practices and committed forgotten handlers for borg role
-rw-r--r--files/borg.fact4
-rw-r--r--handlers/main.yml6
-rw-r--r--templates/backup.sh.j212
-rw-r--r--vars/Alpine.yml2
-rw-r--r--vars/Gentoo.yml2
-rw-r--r--vars/OpenBSD.yml2
6 files changed, 23 insertions, 5 deletions
diff --git a/files/borg.fact b/files/borg.fact
index 555143d..ee6504c 100644
--- a/files/borg.fact
+++ b/files/borg.fact
@@ -1,4 +1,8 @@
#!/bin/sh
+###############################################################################
+# \_o< WARNING : This file is being managed by ansible! >o_/ #
+# ~~~~ ~~~~ #
+###############################################################################
echo '{'
if [ -e '/root/.ssh/borg.pub' ]; then
diff --git a/handlers/main.yml b/handlers/main.yml
new file mode 100644
index 0000000..fed8e07
--- /dev/null
+++ b/handlers/main.yml
@@ -0,0 +1,6 @@
+---
+- name: reload openbsd cron
+ service:
+ name: cron
+ state: reloaded
+...
diff --git a/templates/backup.sh.j2 b/templates/backup.sh.j2
index a029080..6549fe2 100644
--- a/templates/backup.sh.j2
+++ b/templates/backup.sh.j2
@@ -1,11 +1,19 @@
#!/bin/sh
+###############################################################################
+# \_o< WARNING : This file is being managed by ansible! >o_/ #
+# ~~~~ ~~~~ #
+###############################################################################
+
+HOME=/root
+PATH=${PATH}:/usr/local/bin
+BORG_RSH="ssh -i /root/.ssh/borg"
{% for job in borg_jobs %}
{% if job.command_to_pipe is defined %}
{{ job.command_to_pipe }} | BORG_RSH="ssh -i /root/.ssh/borg" borg create borg@{{ borg_server }}:/srv/borg/repos/{{ ansible_hostname }}::{{ job.name }}-{now} {{ job.path | default('-') }}
{% else %}
-BORG_RSH="ssh -i /root/.ssh/borg" borg create borg@{{ borg_server }}:/srv/borg/repos/{{ ansible_hostname }}::{{ job.name }}-{now} {{ job.path }}
+borg create borg@{{ borg_server }}:/srv/borg/repos/{{ ansible_hostname }}::{{ job.name }}-{now} {{ job.path }}
{% endif %}
{% endfor %}
-BORG_RSH="ssh -i /root/.ssh/borg" borg prune borg@{{ borg_server }}:/srv/borg/repos/{{ ansible_hostname }} {{ borg_prune_arguments }}
+borg prune borg@{{ borg_server }}:/srv/borg/repos/{{ ansible_hostname }} {{ borg_prune_arguments }}
diff --git a/vars/Alpine.yml b/vars/Alpine.yml
index ff545b1..83a9fbe 100644
--- a/vars/Alpine.yml
+++ b/vars/Alpine.yml
@@ -1,4 +1,4 @@
---
borg_packages:
- - 'borgbackup'
+ - borgbackup
...
diff --git a/vars/Gentoo.yml b/vars/Gentoo.yml
index a9eb31c..3f81849 100644
--- a/vars/Gentoo.yml
+++ b/vars/Gentoo.yml
@@ -1,4 +1,4 @@
---
borg_packages:
- - 'app-backup/borgbackup'
+ - app-backup/borgbackup
...
diff --git a/vars/OpenBSD.yml b/vars/OpenBSD.yml
index ff545b1..83a9fbe 100644
--- a/vars/OpenBSD.yml
+++ b/vars/OpenBSD.yml
@@ -1,4 +1,4 @@
---
borg_packages:
- - 'borgbackup'
+ - borgbackup
...