ansible/roles/backups/tasks/main.yml

32 lines
779 B
YAML
Raw Normal View History

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up general backups
block:
- name: Create backups directories
file:
state: directory
mode: "0700"
path: "{{ item }}"
loop:
- "/opt/backups"
- "/opt/backups/modules"
- "{{ backups_outdir }}"
- name: Create /backups symlink
file:
state: link
path: "/backups"
src: "{{ backups_outdir }}"
- name: Template out backup script
template:
src: "backup.sh"
dest: "/opt/backups/backup.sh"
mode: "0700"
- name: Set backup cronjob
cron:
minute: "0"
hour: "*/6"
name: ansible-backup
job: "/opt/backups/backup.sh >> /backups/backups.log 2>&1"
become: yes