1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic_archiver.git synced 2024-08-16 10:09:49 +02:00
ansible_role_restic_archiver/tasks/distribution/Linux.yml
2022-03-27 22:41:36 +02:00

56 lines
1.8 KiB
YAML

---
# tasks file for skeleton
- name: reformat dict if necessary
ansible.builtin.set_fact:
restic_archiver__backups: "{{ restic_archiver__backups|dict2items|json_query('[*].value') }}"
when:
- restic_archiver__backups | type_debug == "dict"
- name: Create backup credentials
ansible.builtin.template:
src: restic_access_Linux.j2
dest: '{{ restic_script_dir }}/access-{{ item.name }}.sh'
mode: '0700'
owner: '{{ restic_dir_owner }}'
group: '{{ restic_dir_group }}'
no_log: true
with_items: '{{ restic_archiver__backups }}'
when:
- item.name is defined
- item.src is defined or item.stdin is defined
- item.src is defined or item.stdin and item.stdin_cmd is defined
- item.repo in restic_repos
- name: Create backup script
ansible.builtin.template:
src: restic_script_Linux.j2
dest: '{{ restic_script_dir }}/backup-{{ item.name }}.sh'
mode: '0700'
owner: '{{ restic_dir_owner }}'
group: '{{ restic_dir_group }}'
no_log: true
with_items: '{{ restic_archiver__backups }}'
when:
- item.name is defined
- item.src is defined or item.stdin is defined
- item.src is defined or item.stdin and item.stdin_cmd is defined
- item.repo in restic_repos
- name: Setup CRON jobs
ansible.builtin.cron:
name: 'do1jlr.restic_archiver {{ item.name }}'
job: 'CRON=true {{ restic_script_dir }}/backup-{{ item.name }}.sh'
minute: '{{ item.schedule_minute | default("*") }}'
hour: '{{ item.schedule_hour | default("*") }}'
weekday: '{{ item.schedule_weekday | default("*") }}'
month: '{{ item.schedule_month | default("*") }}'
cron_file: '/etc/crontab'
state: present
become: true
no_log: true
with_items: '{{ restic_archiver__backups }}'
when:
- restic_create_cron
- item.name is defined
- item.scheduled | default(false)