Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
cleanup (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfantom authored and donat-b committed Jan 7, 2018
1 parent 5c064b4 commit 8a827d3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 29 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ Role Variables
--------------

```yaml
restic_install_path: '/usr/local/bin'
restic_password_path: '/var/lib/restic'
restic_version: '0.8.1'
restic_url: ''

restic_download_path: '/opt/restic'
restic_install_path: '/usr/local/bin'

restic_jobs: []
restic_jobs_raw: []
restic_repos:
- name: example
url: '/backup'
Expand Down
11 changes: 6 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---

restic_download_path: '/opt/restic'
restic_install_path: '/usr/local/bin'
restic_url: 'https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_{{ _platform_suffix }}.bz2'

restic_version: '0.8.1'
restic_url: ''

_restic_binpath_tpl: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
restic_download_path: '/opt/restic'
restic_install_path: '/usr/local/bin'

restic_repos: []

restic_jobs: []
restic_jobs_raw: []
5 changes: 4 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ galaxy_info:
author: donat-b
description: Restic is a simple and effective backup solution
license: BSD
min_ansible_version: 2.4
min_ansible_version: 2.2
platforms:
- name: Debian
versions:
Expand All @@ -19,6 +19,9 @@ galaxy_info:
- xenial
- yakkety
- zesty
- name: EL
versions:
- 7
galaxy_tags:
- system
- backup
Expand Down
27 changes: 7 additions & 20 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
---

- name: Set internal variable platform-suffix
set_fact:
_platform_suffix: 'linux_amd64'
when: ansible_userspace_bits == '64'

- name: Set internal variable platform-suffix
- name: Set restic_url
set_fact:
_platform_suffix: 'linux_386'
when: ansible_userspace_bits == '32'

- name: Check if binary is present
stat:
path: '{{ _restic_binpath_tpl }}'
register: restic_executable
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
when: restic_executable.stat.exists == False

- name: Decompress the binary
shell: bzip2 -dc {{ get_url_restic.dest }} > {{ _restic_binpath_tpl }}
shell: "bzip2 -dc {{ get_url_restic.dest }} > {{ restic_download_path }}/bin/restic-{{ restic_version }}"
args:
creates: '{{ _restic_binpath_tpl }}'
when: restic_executable.stat.exists == False
creates: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'

- name: Ensure permissions are correct
file:
path: '{{ _restic_binpath_tpl }}'
path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
mode: '0755'
owner: 'root'
group: 'root'

- name: Create symbolic link to the correct version
file:
src: '{{ _restic_binpath_tpl }}'
src: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
path: '{{ restic_install_path }}/restic'
state: link
force: True
7 changes: 6 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Ensure restic directories exist
file:
state: 'directory'
Expand All @@ -11,8 +10,14 @@
- '/var/log/restic'
- '{{ restic_download_path }}/bin'

- name: Check if binary is present
stat:
path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
register: restic_executable

- name: Install restic
include: 'install.yml'
when: not restic_executable.stat.exists

- name: Configure restic jobs
include: 'configure.yml'
6 changes: 6 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_platform_map:
i386: 386
x86_64: amd64
aarch64: arm64
armv7l: arm
armv6l: arm

0 comments on commit 8a827d3

Please sign in to comment.