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
|
- include_tasks: versioncheck.yml
|
||||||
when: submodules_versioncheck|bool
|
when: submodules_versioncheck|bool
|
||||||
|
|
||||||
- name: add OS specific variables
|
- include_tasks: template.yml
|
||||||
include_vars: '{{ loop_vars }}'
|
|
||||||
with_first_found:
|
#- name: add OS specific variables
|
||||||
- files:
|
# include_vars: '{{ loop_vars }}'
|
||||||
- '{{ distribution }}-{{ distribution_version }}.yml'
|
# with_first_found:
|
||||||
- '{{ distribution }}-{{ distribution_major_version }}.yml'
|
# - files:
|
||||||
- '{{ distribution }}.yml'
|
# - '{{ distribution }}-{{ distribution_version }}.yml'
|
||||||
- '{{ ansible_os_family }}.yml'
|
# - '{{ distribution }}-{{ distribution_major_version }}.yml'
|
||||||
- '{{ ansible_system }}.yml'
|
# - '{{ distribution }}.yml'
|
||||||
- 'defaults.yml'
|
# - '{{ ansible_os_family }}.yml'
|
||||||
paths:
|
# - '{{ ansible_system }}.yml'
|
||||||
- 'vars'
|
# - 'defaults.yml'
|
||||||
loop_control:
|
# paths:
|
||||||
loop_var: loop_vars
|
## - 'vars'
|
||||||
vars:
|
# loop_control:
|
||||||
distribution: '{{ ansible_distribution }}'
|
# loop_var: loop_vars
|
||||||
distribution_version: '{{ ansible_distribution_version }}'
|
# vars:
|
||||||
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
# distribution: '{{ ansible_distribution }}'
|
||||||
tags:
|
# distribution_version: '{{ ansible_distribution_version }}'
|
||||||
- configuration
|
# distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||||
- packages
|
# tags:
|
||||||
|
# - configuration
|
||||||
|
# - packages
|
||||||
|
|
||||||
- name: Ensure restic directories exist
|
- name: Ensure restic directories exist
|
||||||
file:
|
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