diff --git a/CHANGELOG.md b/CHANGELOG.md index b549510..23de919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm and [human-readable changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +* Sanity check for restic binary + ## [0.2.7] 2020-08-05 ### Added * Config option to exclude files diff --git a/tasks/install.yml b/tasks/install.yml index 1cc7e35..4ce6ea9 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -21,6 +21,24 @@ owner: '{{ restic_dir_owner }}' group: '{{ restic_dir_group }}' +- name: Test the binary + shell: "{{ restic_bin_bath }} version" + ignore_errors: true + register: restic_test_result + +- name: Remove faulty binary + file: + path: '{{ restic_bin_bath }}' + state: absent + when: "'FAILED' in restic_test_result.stderr" + +- name: Fail if restic could not be installed + 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: src: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'