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:
commit
45cf3baa52
8 changed files with 60 additions and 51 deletions
|
@ -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
|
||||
|
|
|
@ -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) }}'
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
daemon_reload: true
|
||||
masked: false
|
||||
with_items: '{{ restic_backups }}'
|
||||
ignore_errors: true
|
||||
when:
|
||||
- restic_create_schedule
|
||||
- item.name is defined
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,47 +1,51 @@
|
|||
---
|
||||
- name: Download client binary
|
||||
get_url:
|
||||
- name: install and verify restic binary
|
||||
block:
|
||||
- name: Download client binary
|
||||
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 }}"
|
||||
# TODO: This needs to become independent of the shell module to actually work
|
||||
- name: Decompress the binary
|
||||
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:
|
||||
- name: Ensure permissions are correct
|
||||
ansible.builtin.file:
|
||||
path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
|
||||
mode: '0755'
|
||||
owner: '{{ restic_dir_owner }}'
|
||||
group: '{{ restic_dir_group }}'
|
||||
|
||||
- name: Test the binary
|
||||
- name: Test the binary
|
||||
ansible.builtin.command: "{{ restic_bin_bath }} version"
|
||||
ignore_errors: true
|
||||
register: restic_test_result
|
||||
|
||||
- name: Remove faulty binary
|
||||
file:
|
||||
- name: Remove faulty binary
|
||||
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:
|
||||
- name: Fail if restic could not be installed
|
||||
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:
|
||||
- name: Create symbolic link to the correct version
|
||||
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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue