From fc5ef9190e8752941963177df34a1be5a3f941b3 Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Tue, 13 Aug 2019 13:52:25 +0200 Subject: [PATCH] initializing repository --- tasks/configure.yml | 16 ++++++++++++++++ tasks/main.yml | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tasks/configure.yml diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..7a70dac --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,16 @@ +--- +- name: Initialize repository + command: '{{ restic_install_path }}/restic init' + environment: + RESTIC_REPOSITORY: '{{ item.value.location }}' + RESTIC_PASSWORD: '{{ item.value.password }}' + no_log: True + register: restic_init + changed_when: "'created restic repository' in restic_init.stdout" + failed_when: + - restic_init.rc != 0 + - not 'config file already exists' in restic_init.stderr + loop: "{{ restic_repos|dict2items }}" + when: + - item.value.init is defined + - item.value.init == true diff --git a/tasks/main.yml b/tasks/main.yml index 219a7ba..685812e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -32,8 +32,22 @@ group: '{{ restic_dir_group }}' with_items: '{{ restic_create_paths }}' +- name: Check if downloaded binary is present + stat: + path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}' + register: restic_executable + +- name: Check if installed binary is present + stat: + path: '{{ restic_install_path }}/restic' + register: restic_installed + - name: Install restic include: 'install.yml' + when: not restic_executable.stat.exists or not restic_installed.stat.exists + +- name: Configure restic + include: 'configure.yml' - name: include distribution tasks include_tasks: '{{ loop_distribution }}'