1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic.git synced 2024-12-11 23:41:32 +01:00

Merge pull request #24 from roles-ansible/0.12.1

update restic to 0.12.1 and update update mechanism
This commit is contained in:
L3D 2021-08-03 23:20:44 +02:00 committed by GitHub
commit 45cf3baa52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 51 deletions

View file

@ -66,7 +66,7 @@ ansible-galaxy install arillso.restic
| Name | Default | Description |
| ---------------------- | ----------------------------------- | --------------------------------------------------------------------------- |
| `restic_url` | `undefined` | The URL to download restic from. Use this variable to overwrite the default |
| `restic_version` | `'0.12.0'` | The version of Restic to install |
| `restic_version` | `'0.12.1'` | The version of Restic to install |
| `restic_download_path` | `'/opt/restic'` | Download location for the restic binary |
| `restic_install_path` | `'/usr/local/bin'` | Install location for the restic binary |
| `restic_script_dir` | `'/opt/restic'` | Location of the generated backup scripts |
@ -77,6 +77,7 @@ ansible-galaxy install arillso.restic
| `restic_schedule_type` | `systemd` | Here you can define if we create a ``cronjob`` or a ``systemd`` timer. If it fails to create a systemd timer, a cronjob will be created. |
| `restic_dir_owner` | `'{{ansible_user}}'` | The owner of all created dirs |
| `restic_dir_group` | `'{{ansible_user}}'` | The group of all created dirs |
| `restic_no_log` | `true` | set to false to see hidden ansible logs |
### Repos
Restic stores data in repositories. You have to specify at least one repository

View file

@ -1,7 +1,7 @@
---
# defaults file for skeleton
restic_url: '{{ restic_url_default }}'
restic_version: '0.12.0'
restic_version: '0.12.1'
restic_download_path: '/opt/restic'
restic_install_path: '/usr/bin'
restic_script_dir: '/opt/restic'
@ -11,6 +11,7 @@ restic_backups: []
restic_create_schedule: "{{ restic_create_cron }}"
restic_schedule_type: "systemd"
# restic_schedule_type: "cronjob"
restic_no_log: true
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}'

View file

@ -7,6 +7,7 @@
daemon_reload: true
masked: false
with_items: '{{ restic_backups }}'
ignore_errors: true
when:
- restic_create_schedule
- item.name is defined

View file

@ -12,7 +12,7 @@
mode: '0700'
owner: '{{ restic_dir_owner }}'
group: '{{ restic_dir_group }}'
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- item.name is defined
@ -27,7 +27,7 @@
mode: '0700'
owner: '{{ restic_dir_owner }}'
group: '{{ restic_dir_group }}'
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- item.name is defined

View file

@ -12,7 +12,7 @@
AWS_DEFAULT_REGION: '{{ item.value.aws_default_region | default("") }}'
B2_ACCOUNT_ID: '{{ item.value.b2_account_id | default("") }}'
B2_ACCOUNT_KEY: '{{ item.value.b2_account_key | default("") }}'
no_log: true
no_log: "{{ restic_no_log }}"
register: restic_init
changed_when: "'created restic repository' in restic_init.stdout"
failed_when:

View file

@ -1,21 +1,21 @@
---
- name: install and verify restic binary
block:
- name: Download client binary
get_url:
ansible.builtin.get_url:
url: '{{ restic_url }}'
dest: '{{ restic_download_path }}/restic.bz2'
force: true
register: get_url_restic
# TODO: This needs to become independent of the shell module to actually work
# on every system. We could use a distribution specific aproach, but this would
# conflict with the current structure in tasks/distribution/
- name: Decompress the binary
shell: "bzip2 -dc {{ get_url_restic.dest }} > {{ restic_bin_bath }}"
ansible.builtin.shell: "bzip2 -dc {{ get_url_restic.dest }} > {{ restic_bin_bath }}"
args:
creates: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
- name: Ensure permissions are correct
file:
ansible.builtin.file:
path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
mode: '0755'
owner: '{{ restic_dir_owner }}'
@ -27,21 +27,25 @@
register: restic_test_result
- name: Remove faulty binary
file:
ansible.builtin.file:
path: '{{ restic_bin_bath }}'
state: absent
when: "'FAILED' in restic_test_result.stderr"
- name: Fail if restic could not be installed
fail:
ansible.builtin.fail:
msg: >-
Restic binary has been faulty and has been removed.
Try to re-run the role and make sure you have bzip2 installed!
when: "'FAILED' in restic_test_result.stderr"
- name: Create symbolic link to the correct version
file:
ansible.builtin.file:
src: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
path: '{{ restic_install_path }}/restic'
state: link
force: true
rescue:
- name: try restic self-update
become: true
ansible.builtin.command: "{{ restic_install_path }}/restic self-update"

View file

@ -9,7 +9,7 @@
owner: 'root'
group: 'root'
mode: '0644'
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
notify: systemctl restart restic.timer
when:
@ -24,7 +24,7 @@
owner: 'root'
group: 'root'
mode: '0644'
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- item.name is defined
@ -38,7 +38,7 @@
owner: 'root'
group: 'root'
mode: '0644'
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- item.name is defined
@ -83,7 +83,7 @@
cron_file: '/etc/crontab'
user: 'root'
become: true
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- item.name is defined
@ -109,7 +109,7 @@
cron_file: '/etc/crontab'
user: 'root'
become: true
no_log: true
no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}'
when:
- restic_create_schedule | bool
@ -124,6 +124,7 @@
enabled: false
masked: true
with_items: '{{ restic_backups }}'
ignore_errors: true
when:
- restic_create_schedule | bool
- item.name is defined
@ -137,6 +138,7 @@
enabled: false
masked: true
with_items: '{{ restic_backups }}'
ignore_errors: true
when:
- restic_create_schedule | bool
- item.name is defined

View file

@ -10,5 +10,5 @@ restic_os_variables:
paths:
- 'vars'
playbook_version_number: 14 # should be int
playbook_version_number: 16 # should be int
playbook_version_path: 'do1jlr.restic.version'