download restic binary, validate shasum and unzip it
This commit is contained in:
parent
cc30a458f3
commit
85fd6698d3
|
@ -1,5 +1,5 @@
|
|||
[jake]
|
||||
jake.box.nilsnh.no ansible_user=jake
|
||||
|
||||
[this_machine_localhost]
|
||||
[this_machine]
|
||||
localhost ansible_connection=local
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
forgejo_from: "\"Forgejo at nilsnh.no\" <{{ machine_from_email }}>"
|
||||
roles:
|
||||
- backup
|
||||
- sendmail
|
||||
- forgejo
|
||||
- caddy
|
||||
# - sendmail
|
||||
# - forgejo
|
||||
# - caddy
|
||||
|
||||
# - hosts: mr-mittens
|
||||
# handlers:
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
- name: upload restic binary
|
||||
ansible.builtin.copy:
|
||||
src: restic-arm64
|
||||
dest: /usr/local/bin/restic
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
- name: check if Restic is installed
|
||||
shell: /usr/local/bin/restic version | awk '{print $2}'
|
||||
register: restic_found_version
|
||||
changed_when: false
|
||||
|
||||
- name: download restic binary
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ restic_download_url }}"
|
||||
dest: /usr/local/bin/restic.bz2
|
||||
checksum: "{{ restic_checksum }}"
|
||||
mode: '711'
|
||||
when:
|
||||
- restic_version != restic_found_version.stdout
|
||||
|
||||
- name: unarchive restic binary
|
||||
ansible.builtin.shell: bzip2 --decompress --force /usr/local/bin/restic.bz2
|
||||
when:
|
||||
- restic_version != restic_found_version.stdout
|
||||
|
||||
- name: upload restic.sh script
|
||||
ansible.builtin.template:
|
||||
|
|
19
roles/backup/vars/main.yml
Normal file
19
roles/backup/vars/main.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
restic_version: "0.16.3"
|
||||
|
||||
# Map Ansible architectures to how Restic defines them.
|
||||
architecture_mappings:
|
||||
aarch64: arm64
|
||||
x86_64: amd64
|
||||
restic_architecture: "{{ architecture_mappings[ansible_facts['architecture']] }}"
|
||||
|
||||
# example filename: restic_0.16.3_linux_arm64.bz2
|
||||
# see also: https://github.com/restic/restic/releases
|
||||
restic_filename: "restic_{{ restic_version }}_{{ ansible_facts['system'] | lower }}_{{ restic_architecture }}.bz2"
|
||||
restic_download_url: "https://github.com/restic/restic/releases/download/v{{ restic_version }}/{{ restic_filename }}"
|
||||
restic_checksum_arm64: sha256:7fdc003748c1fa5ff0d87a64aaa8a029927596db53ee09248494aaebe3970179
|
||||
restic_checksum_amd64: sha256:aa86e5667c46ab0bdf8ceca80fa3c8775da2bbc18656250a745ac8b042837a70
|
||||
# Select proper checksum based on the host architecture
|
||||
restic_checksum: "{{ lookup('ansible.builtin.vars', 'restic_checksum_%s'|format(restic_architecture)) }}"
|
||||
|
||||
# Build up some good urls here.
|
Loading…
Reference in a new issue