mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
update archiver f00
This commit is contained in:
parent
e655bfa69e
commit
1c423fb742
3 changed files with 77 additions and 27 deletions
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
# tasks file for skeleton
|
||||
|
||||
- name: Message
|
||||
debug:
|
||||
msg: 'Your {{ ansible_system }} is not supported'
|
|
@ -2,27 +2,29 @@
|
|||
- include_tasks: versioncheck.yml
|
||||
when: submodules_versioncheck|bool
|
||||
|
||||
- name: add OS specific variables
|
||||
include_vars: '{{ loop_vars }}'
|
||||
with_first_found:
|
||||
- files:
|
||||
- '{{ distribution }}-{{ distribution_version }}.yml'
|
||||
- '{{ distribution }}-{{ distribution_major_version }}.yml'
|
||||
- '{{ distribution }}.yml'
|
||||
- '{{ ansible_os_family }}.yml'
|
||||
- '{{ ansible_system }}.yml'
|
||||
- 'defaults.yml'
|
||||
paths:
|
||||
- 'vars'
|
||||
loop_control:
|
||||
loop_var: loop_vars
|
||||
vars:
|
||||
distribution: '{{ ansible_distribution }}'
|
||||
distribution_version: '{{ ansible_distribution_version }}'
|
||||
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||
tags:
|
||||
- configuration
|
||||
- packages
|
||||
- include_tasks: template.yml
|
||||
|
||||
#- name: add OS specific variables
|
||||
# include_vars: '{{ loop_vars }}'
|
||||
# with_first_found:
|
||||
# - files:
|
||||
# - '{{ distribution }}-{{ distribution_version }}.yml'
|
||||
# - '{{ distribution }}-{{ distribution_major_version }}.yml'
|
||||
# - '{{ distribution }}.yml'
|
||||
# - '{{ ansible_os_family }}.yml'
|
||||
# - '{{ ansible_system }}.yml'
|
||||
# - 'defaults.yml'
|
||||
# paths:
|
||||
## - 'vars'
|
||||
# loop_control:
|
||||
# loop_var: loop_vars
|
||||
# vars:
|
||||
# distribution: '{{ ansible_distribution }}'
|
||||
# distribution_version: '{{ ansible_distribution_version }}'
|
||||
# distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||
# tags:
|
||||
# - configuration
|
||||
# - packages
|
||||
|
||||
- name: Ensure restic directories exist
|
||||
file:
|
||||
|
|
54
tasks/template.yml
Normal file
54
tasks/template.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
- name: reformat dict if necessary
|
||||
set_fact:
|
||||
restic_archiver__backups: "{{ restic_archiver__backups|dict2items|json_query('[*].value') }}"
|
||||
when:
|
||||
- restic_archiver__backups | type_debug == "dict"
|
||||
|
||||
- name: Create backup credentials
|
||||
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
|
||||
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
|
||||
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)
|
Loading…
Reference in a new issue