# Copyright (C) 2021 Kris Lamoureux # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - name: Install rsnapshot ansible.builtin.apt: name: rsnapshot state: present - name: Create rsnapshot system directories ansible.builtin.file: path: "{{ item }}" state: directory loop: - "{{ rsnapshot_confdir }}" - "{{ rsnapshot_logdir }}" - name: Create snapshot_root directories ansible.builtin.file: path: "{{ item.root | default(rsnapshot_root) }}" state: directory loop: "{{ rsnapshot }}" - name: Install rsnapshot configuration ansible.builtin.template: src: rsnapshot.conf.j2 dest: "{{ rsnapshot_confdir }}/{{ item.name }}.conf" loop: "{{ rsnapshot }}" - name: Install rsnapshot crons ansible.builtin.cron: name: "{{ item.1.interval }} rsnapshot of {{ item.0.name }}" job: "/usr/bin/rsnapshot -c {{ rsnapshot_confdir }}/{{ item.0.name }}.conf {{ item.1.interval }} >/dev/null" user: "root" minute: "{{ item.1.minute | default('*') }}" hour: "{{ item.1.hour | default('*') }}" day: "{{ item.1.day | default('*') }}" weekday: "{{ item.1.weekday | default('*') }}" month: "{{ item.1.month | default('*') }}" cron_file: "rsnapshot-{{ item.0.name }}" with_subelements: - "{{ rsnapshot }}" - cron - name: Install rsnapshot report script ansible.builtin.template: src: rsnapshot-report.sh.j2 dest: /usr/local/bin/rsnapshot-report mode: '0750' - name: Install rsnapshot report crons ansible.builtin.cron: name: "{{ item.name }} rsnapshot report email" job: "/usr/local/bin/rsnapshot-report {{ rsnapshot_reportlog }} | mail -s '{{ item.report.subject | default('Backup Report') }}' {{ item.report.to }}" user: "root" minute: '0' hour: '0' cron_file: "rsnapshot-{{ item.name }}" loop: "{{ rsnapshot }}" when: item.report is defined