#!/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" - "/backups" - "/opt/backups/modules" - name: Template out backup script template: src: "backup.sh" dest: "/opt/backups/backup.sh" mode: "0700" - name: Set backup cronjob cron: minute: "0" hour: "2" name: ansible-backup job: "/opt/backups/backup.sh >> /backups/backups.log 2>&1" become: yes