2019-12-15 06:40:49 +00:00
|
|
|
---
|
|
|
|
- name: gather os specific variables
|
2022-08-31 03:19:06 +00:00
|
|
|
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
2019-12-15 06:40:49 +00:00
|
|
|
vars:
|
2022-08-31 03:19:06 +00:00
|
|
|
params:
|
2019-12-15 06:40:49 +00:00
|
|
|
files:
|
|
|
|
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
|
|
|
- "{{ ansible_distribution }}.yaml"
|
|
|
|
- "{{ ansible_os_family }}.yaml"
|
|
|
|
- "default.yaml"
|
|
|
|
paths:
|
|
|
|
- vars
|
|
|
|
|
|
|
|
- name: include os specific tasks
|
2022-08-31 03:19:06 +00:00
|
|
|
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
|
2019-12-15 06:40:49 +00:00
|
|
|
vars:
|
2022-08-31 03:19:06 +00:00
|
|
|
params:
|
2019-12-15 06:40:49 +00:00
|
|
|
files:
|
|
|
|
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
|
|
|
- "{{ ansible_distribution }}.yaml"
|
|
|
|
- "{{ ansible_os_family }}.yaml"
|
|
|
|
- "default.yaml"
|
|
|
|
paths:
|
|
|
|
- tasks
|
|
|
|
|
|
|
|
- name: "download restic {{ restic_version }}"
|
|
|
|
get_url:
|
|
|
|
url: "{{ restic_url }}"
|
|
|
|
checksum: "{{ restic_checksum }}"
|
|
|
|
dest: "{{ restic_path }}.bz2"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0400
|
|
|
|
register: dl
|
|
|
|
|
|
|
|
- name: determine if restic exists
|
|
|
|
stat:
|
|
|
|
path: "{{ restic_path }}"
|
|
|
|
register: st
|
|
|
|
|
|
|
|
- name: decompress restic
|
|
|
|
command:
|
|
|
|
cmd: "bunzip2 -k {{ restic_path }}.bz2"
|
|
|
|
creates: "{{ restic_path }}"
|
|
|
|
when: dl.changed or not st.stat.exists
|
|
|
|
#notify:
|
|
|
|
# - restart restic
|
|
|
|
|
|
|
|
- name: manage restic attributes
|
|
|
|
file:
|
|
|
|
path: "{{ restic_path }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: create etc tree
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
loop:
|
|
|
|
- "{{ restic_etc_path }}"
|
|
|
|
- "{{ restic_etc_path }}/repos"
|
|
|
|
- "{{ restic_etc_path }}/jobs"
|
|
|
|
|
2020-04-21 03:28:32 +00:00
|
|
|
- name: create environment helper
|
|
|
|
template:
|
|
|
|
src: env.sh.j2
|
|
|
|
dest: "{{ restic_etc_path }}/env.sh"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0400
|
|
|
|
|
2019-12-19 04:09:05 +00:00
|
|
|
- name: copy restic helper scripts
|
|
|
|
copy:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ restic_bin_path }}/{{ item | basename | splitext | first }}"
|
2019-12-16 02:51:51 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
2019-12-19 04:09:05 +00:00
|
|
|
loop:
|
|
|
|
- restic-tidy.sh
|
|
|
|
- restic-repo.sh
|
|
|
|
- restic-job.sh
|
2019-12-16 02:51:51 +00:00
|
|
|
|
2019-12-15 06:40:49 +00:00
|
|
|
- name: manage repos
|
2022-08-31 03:19:06 +00:00
|
|
|
ansible.builtin.include_tasks: repo.yaml
|
2019-12-15 06:40:49 +00:00
|
|
|
loop: "{{ restic_repos | default([]) }}"
|
|
|
|
|
|
|
|
- name: manage jobs
|
2022-08-31 03:19:06 +00:00
|
|
|
ansible.builtin.include_tasks: job.yaml
|
2019-12-15 06:40:49 +00:00
|
|
|
loop: "{{ restic_jobs | default([]) }}"
|