diff --git a/meta/main.yml b/meta/main.yml index 95d7d59..e775f4a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -4,7 +4,7 @@ galaxy_info: author: L3D description: Role to deploy restic and setup backups. license: MIT - min_ansible_version: 2.8 + min_ansible_version: 2.11 platforms: - name: Debian versions: diff --git a/tasks/cron.yml b/tasks/cron.yml index 21068a0..956268d 100644 --- a/tasks/cron.yml +++ b/tasks/cron.yml @@ -1,13 +1,13 @@ --- - name: install cron become: true - package: + ansible.builtin.package: name: "{{ restic_archiver__package }}" state: present - name: setup cronjob for restic with logging become: true - cron: + ansible.builtin.cron: name: "archive restic backup with ansible_role_restic_archiver" job: /opt/restic-backup.sh >> /var/log/restic/restic_archiver.log cron_file: /etc/crontab @@ -18,7 +18,7 @@ - name: setup cronjob for restic without logging become: true - cron: + ansible.builtin.cron: name: "archive restic backup with ansible_role_restic_archiver" job: /opt/restic-backup.sh cron_file: /etc/crontab diff --git a/tasks/logs.yml b/tasks/logs.yml index 9416a6d..78a8495 100644 --- a/tasks/logs.yml +++ b/tasks/logs.yml @@ -1,7 +1,7 @@ --- - name: create /var/log/restic/ become: true - file: + ansible.builtin.file: path: /var/log/restic state: directory recurse: true @@ -11,14 +11,14 @@ - name: install logrotate become: true - package: + ansible.builtin.package: name: logrotate state: present when: restic_archiver__logrotate | bool - name: create logrotate config become: true - copy: + ansible.builtin.copy: src: files/logrotate.conf dest: /etc/logrotate.d/restic group: "{{ restic_archiver__owner }}" diff --git a/tasks/mail.yml b/tasks/mail.yml index 7fc447f..fe86ad5 100644 --- a/tasks/mail.yml +++ b/tasks/mail.yml @@ -1,7 +1,7 @@ --- - name: install requirements become: true - package: + ansible.builtin.package: name: - jq - bsd-mailx diff --git a/tasks/main.yml b/tasks/main.yml index 9f479d4..0cf35ec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,10 @@ --- -- include_tasks: versioncheck.yml +- name: run optional versionscheck + ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool - name: deploy restic template - template: + ansible.builtin.template: src: templates/restic_forget_snapshots.j2 dest: /opt/restic-backup.sh group: "{{ restic_archiver__owner }}" @@ -11,10 +12,14 @@ mode: 0700 become: true -- include_tasks: logs.yml +- name: setup logrotate + ansible.builtin.include_tasks: logs.yml when: restic_archiver__log_output | bool -- include_tasks: cron.yml +- name: create cronjob + ansible.builtin.include_tasks: cron.yml +# todo: replace with systemd timer -- include_tasks: mail.yml +- name: install requirements for mailing + ansible.builtin.include_tasks: mail.yml when: restic_archiver__mailsummary | bool diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index dca3e47..5128cc8 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -1,4 +1,7 @@ --- +# Copyright (c) 2021 L3D +# this file is released with the MIT license. +# License: https://github.com/roles-ansible/ansible_role_template/blob/main/LICENSE - name: Create directory for versionscheck become: true ansible.builtin.file: @@ -32,11 +35,6 @@ when: - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool -- name: check if '/etc/ansible-version/' is empty - ansible.builtin.find: - paths: '/etc/ansible-version/' - register: filesFound - - name: write new version to remote disk become: true ansible.builtin.copy: diff --git a/vars/main.yml b/vars/main.yml index 75514ab..73731df 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 43 # should be int +playbook_version_number: 44 # should be int playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'