mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-05 03:23:29 +01:00
installing binary
This commit is contained in:
parent
58f87376b8
commit
4d311e5727
4 changed files with 108 additions and 2 deletions
|
@ -1,8 +1,13 @@
|
||||||
---
|
---
|
||||||
# defaults file for skeleton
|
# defaults file for skeleton
|
||||||
|
restic_url: ''
|
||||||
restic_version: '0.9.5'
|
restic_version: '0.9.5'
|
||||||
restic_install_dir: '/usr/bin'
|
restic_download_path: '/opt/restic'
|
||||||
|
restic_install_path: '/usr/bin'
|
||||||
restic_script_dir: '~/restic'
|
restic_script_dir: '~/restic'
|
||||||
restic_repos: {}
|
restic_repos: {}
|
||||||
restic_backups: []
|
restic_backups: []
|
||||||
restic_create_cron: false
|
restic_create_cron: false
|
||||||
|
|
||||||
|
restic_dir_owner: '{{ansible_user}}'
|
||||||
|
restic_dir_group: '{{ansible_user}}'
|
32
tasks/install.yml
Normal file
32
tasks/install.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
- name: Set restic_url
|
||||||
|
set_fact:
|
||||||
|
restic_url: 'https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_{{ ansible_system | lower }}_{{ _platform_map[ansible_architecture] | default(ansible_architecture) }}.bz2'
|
||||||
|
when: restic_url == ''
|
||||||
|
|
||||||
|
- name: Download client binary
|
||||||
|
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
|
||||||
|
- name: Decompress the binary
|
||||||
|
shell: "bzip2 -dc {{ get_url_restic.dest }} > {{ restic_download_path }}/bin/restic-{{ restic_version }}"
|
||||||
|
args:
|
||||||
|
creates: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
|
||||||
|
|
||||||
|
- name: Ensure permissions are correct
|
||||||
|
file:
|
||||||
|
path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
|
||||||
|
mode: '0755'
|
||||||
|
owner: '{{ restic_dir_owner }}'
|
||||||
|
group: '{{ restic_dir_group }}'
|
||||||
|
|
||||||
|
- name: Create symbolic link to the correct version
|
||||||
|
file:
|
||||||
|
src: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
|
||||||
|
path: '{{ restic_install_path }}/restic'
|
||||||
|
state: link
|
||||||
|
force: True
|
58
tasks/main.yml
Normal file
58
tasks/main.yml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
---
|
||||||
|
# tasks file for skeleton
|
||||||
|
|
||||||
|
- name: add OS specific variables
|
||||||
|
include_vars: '{{ loop_vars }}'
|
||||||
|
with_first_found:
|
||||||
|
- files:
|
||||||
|
- '{{ distribution }}-{{ distribution_version }}.yml'
|
||||||
|
- '{{ distribution }}-{{ distribution_major_version }}.yml'
|
||||||
|
- '{{ distribution }}.yml'
|
||||||
|
- '{{ ansible_os_family }}.yml'
|
||||||
|
- '{{ ansible_system }}.yml'
|
||||||
|
- 'defaults.yml'
|
||||||
|
paths:
|
||||||
|
- 'vars'
|
||||||
|
loop_control:
|
||||||
|
loop_var: loop_vars
|
||||||
|
vars:
|
||||||
|
distribution: '{{ ansible_distribution }}'
|
||||||
|
distribution_version: '{{ ansible_distribution_version }}'
|
||||||
|
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
- packages
|
||||||
|
|
||||||
|
- name: Ensure restic directories exist
|
||||||
|
file:
|
||||||
|
state: 'directory'
|
||||||
|
path: '{{ item }}'
|
||||||
|
mode: '0755'
|
||||||
|
owner: '{{ restic_dir_owner }}'
|
||||||
|
group: '{{ restic_dir_group }}'
|
||||||
|
with_items: '{{ restic_create_paths }}'
|
||||||
|
|
||||||
|
- name: Install restic
|
||||||
|
include: 'install.yml'
|
||||||
|
|
||||||
|
- name: include distribution tasks
|
||||||
|
include_tasks: '{{ loop_distribution }}'
|
||||||
|
with_first_found:
|
||||||
|
- files:
|
||||||
|
- '{{ distribution }}-{{ distribution_version }}.yml'
|
||||||
|
- '{{ distribution }}-{{ distribution_major_version }}.yml'
|
||||||
|
- '{{ distribution }}.yml'
|
||||||
|
- '{{ ansible_os_family }}.yml'
|
||||||
|
- '{{ ansible_system }}.yml'
|
||||||
|
- 'defaults.yml'
|
||||||
|
paths:
|
||||||
|
- 'distribution'
|
||||||
|
loop_control:
|
||||||
|
loop_var: loop_distribution
|
||||||
|
vars:
|
||||||
|
distribution: '{{ ansible_distribution }}'
|
||||||
|
distribution_version: '{{ ansible_distribution_version }}'
|
||||||
|
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
- packages
|
11
vars/defaults.yml
Normal file
11
vars/defaults.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
# we use a platform map to decipher system version
|
||||||
|
_platform_map:
|
||||||
|
i386: 386
|
||||||
|
x86_64: amd64
|
||||||
|
aarch64: arm64
|
||||||
|
armv7l: arm
|
||||||
|
armv6l: arm
|
||||||
|
|
||||||
|
restic_create_paths:
|
||||||
|
- '{{ restic_install_path }}/bin'
|
Loading…
Reference in a new issue