diff --git a/tasks/main.yml b/tasks/main.yml index cff401b69b1ac80e8784de4645f22f82f601140d..d601f288e6dec6b6e3331d1a73fa7e8e74bb57cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,4 +12,7 @@ - name: Import spideroak import_tasks: spideroak.yml + - name: Validate Backup + import_tasks: validate.yml + when: (not excluded_roles or "spideroak" not in excluded_roles) and spideroak_username is defined and spideroak_username != "" diff --git a/tasks/spideroak.yml b/tasks/spideroak.yml index 8f7901979a4c1afdf3374030ade04045e766804b..b131cfcb4cd517b04abd60084bc7bb9030b3880e 100644 --- a/tasks/spideroak.yml +++ b/tasks/spideroak.yml @@ -37,6 +37,14 @@ - name: Wait shell: sleep 5 +- name: Ensure Monitoring Directory + file: + path: /var/backups/spideroak-monitoring + state: directory + +- name: Add Monitoring Directory to SpiderOak + shell: SpiderOakONE --include-dir=/var/backups/spideroak-monitoring + - name: Add Directories to SpiderOak shell: SpiderOakONE --include-dir={{ item }} with_items: '{{ spideroak_include|default([]) }}' diff --git a/tasks/validate.yml b/tasks/validate.yml new file mode 100644 index 0000000000000000000000000000000000000000..046ce70200d68a7049d310f0bb3510ebb1050100 --- /dev/null +++ b/tasks/validate.yml @@ -0,0 +1,50 @@ +--- +# file: roles/spideroak/tasks/validate.yml + +- block: + + - name: Generate Random String + set_fact: random_string="{{ lookup('password', '/tmp/passwordfile length=25 chars=ascii_letters,digits') }}" + + - name: Store Random String in validation.txt + copy: + dest: /var/backups/spideroak-monitoring/validation.txt + mode: 0644 + content: '{{ random_string }}' + + tags: + - validation_create_random + +- block: + + - name: Stop SpiderOak + service: + name: spideroak + state: stopped + pattern: SpiderOakONE + + - name: Wait + shell: sleep 5 + + - name: Create File Share + shell: SpiderOakONE --share-single-file=/var/backups/spideroak-monitoring/validation.txt + register: spideroak_validation_link + + - name: Start SpiderOak + service: + name: spideroak + state: started + + - name: Download Share + get_url: + url: '{{ spideroak_validation_link.stdout_lines[0] }}' + dest: /tmp/spideroak.validation + mode: 0644 + + - name: Compare Strings + raw: diff /var/backups/spideroak-monitoring/validation.txt /tmp/spideroak.validation + register: diff_cmd + failed_when: diff_cmd.rc > 0 + + tags: + - validation_verify