summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Fenzi <kevin@scrye.com>2013-07-23 17:26:34 +0000
committerKevin Fenzi <kevin@scrye.com>2013-07-23 17:26:34 +0000
commitde351bea39ad1925f3f7307e46cb69e50ab8800d (patch)
tree96050577b8d5d406895f73364a2d9690322829ea
parent5ae82572f193472c33577763440df18a6a9960df (diff)
downloadansible-de351bea39ad1925f3f7307e46cb69e50ab8800d.tar.gz
ansible-de351bea39ad1925f3f7307e46cb69e50ab8800d.tar.xz
ansible-de351bea39ad1925f3f7307e46cb69e50ab8800d.zip
Very first cut at using ansible to run rdiff backups on backup03
-rw-r--r--files/rdiff-backup/run-rdiff-backups9
-rw-r--r--files/rdiff-backup/run-rdiff-backups.cron3
-rw-r--r--inventory/inventory3
-rw-r--r--playbooks/rdiff-backup.yml36
-rw-r--r--tasks/rdiff_backup_server.yml10
5 files changed, 61 insertions, 0 deletions
diff --git a/files/rdiff-backup/run-rdiff-backups b/files/rdiff-backup/run-rdiff-backups
new file mode 100644
index 000000000..c2e099ec9
--- /dev/null
+++ b/files/rdiff-backup/run-rdiff-backups
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+source /root/sshagent >>/dev/null
+
+TMPDIR=`mktemp -d /tmp/backups.XXXX`
+
+cd $TMPDIR
+git clone http://infrastructure.fedoraproject.org/ansible.git
+ansible-playbook -i ansible/inventory ansible/playbooks/rdiff-backup.yml
diff --git a/files/rdiff-backup/run-rdiff-backups.cron b/files/rdiff-backup/run-rdiff-backups.cron
new file mode 100644
index 000000000..91bff12a0
--- /dev/null
+++ b/files/rdiff-backup/run-rdiff-backups.cron
@@ -0,0 +1,3 @@
+# run rdiff backups
+MAILTO=kevin@scrye.com
+00 22 * * * root /usr/local/bin/lock-wrapper run-rdiff-backups "/usr/local/bin/run-rdiff-backups"
diff --git a/inventory/inventory b/inventory/inventory
index 6d1b6cf66..99cbad967 100644
--- a/inventory/inventory
+++ b/inventory/inventory
@@ -44,6 +44,9 @@ ask01.stg.phx2.fedoraproject.org
backup02.fedoraproject.org
backup03.phx2.fedoraproject.org
+[backup_clients]
+people03.vpn.fedoraproject.org
+
[badges-backend]
badges-backend01.phx2.fedoraproject.org
diff --git a/playbooks/rdiff-backup.yml b/playbooks/rdiff-backup.yml
new file mode 100644
index 000000000..4745b559b
--- /dev/null
+++ b/playbooks/rdiff-backup.yml
@@ -0,0 +1,36 @@
+# all this does is use the ansible scheduler to allow you to fork off
+# a set number of rdiff-backup runs against an array of backup targets
+# Since rdiff-backup doesn't have its own built-in-scheduler
+# this seemed like an obvious cheat
+
+- name: rdiff-backup
+ hosts: backup_clients
+ user: root
+ gather_facts: False
+ # host_backup_targets set in host_vars or group_vars
+ # global_backup_targets can be defined in vars, group_vars/all or anywhere
+ # take the 'echo' out below for it to actually run
+ # FIXME - see how this copes with timeouts
+ # FIXME - storing/reporting results and output?
+ # FIXME - coping with errors?
+
+ vars:
+ - global_backup_targets: ['/etc', '/home']
+
+ tasks:
+ - name: run rdiff-backup hitting all the global targets
+ local_action: "shell echo rdiff-backup ${inventory_hostname}::${item} /fedora_backups/${inventory_hostname}/`basename ${item}`"
+ with_items: $global_backup_targets
+ when: global_backup_targets is defined
+ serial: 5
+ async: 100000
+ poll: 120
+
+ - name: run rdiff-backup hitting all the host targets
+ local_action: "shell echo rdiff-backup ${inventory_hostname}::${item} /fedora_backups/${inventory_hostname}/`basename ${item}`"
+ with_items: $host_backup_targets
+ when: host_backup_targets is defined
+ serial: 5
+ async: 100000
+ poll: 120
+
diff --git a/tasks/rdiff_backup_server.yml b/tasks/rdiff_backup_server.yml
index 35c791757..16cb0e606 100644
--- a/tasks/rdiff_backup_server.yml
+++ b/tasks/rdiff_backup_server.yml
@@ -6,3 +6,13 @@
- rdiff-backup
tags:
- packages
+
+- name: setup rdiff backup script
+ copy: src=$files/rdiff-backup/run-rdiff-backups dest=/usr/local/bin/run-rdiff-backups
+ tags:
+ - config
+
+- name: setup rdiff backup cron
+ cron: cron_file=$files/rdiff-backup/run-rdiff-backups.cron
+ tags:
+ - config