blob: 4b5c18d110f3623eb62079e9571ffaf925794669 [file] [log] [blame]
Michal Ptacekf5907202018-12-19 11:54:34 +00001---
2- name: Upload resources to infrastructure servers over nfs
3 block:
4 - name: Mount resources
5 mount:
6 path: /tmp/resource_data
7 src: "{{ hostvars[groups.resources.0].ansible_host }}:{{ hostvars[groups.resources.0].resources_dir }}"
8 fstype: nfs
9 state: mounted
10
11 - name: Unarchive resources
12 unarchive:
13 src: "/tmp/resource_data/{{ hostvars[groups.resources.0].resources_filename }}"
14 remote_src: yes
15 dest: "{{ app_data_path }}"
16 when: not resources_data_check.stat.exists
17
18 - name: Unarchive auxiliary resources
19 unarchive:
20 src: "/tmp/resource_data/{{ hostvars[groups.resources.0].aux_resources_filename }}"
21 remote_src: yes
22 dest: "{{ aux_data_path }}"
23 when: >
24 hostvars[groups.resources.0].aux_resources_filename is defined
Michal Ptacek173ad8e2019-02-14 07:47:59 +000025 and hostvars[groups.resources.0].aux_resources_filename is not none
Michal Ptacekf5907202018-12-19 11:54:34 +000026 and aux_data_path is defined and aux_data_path is not none
27 and hostvars[groups.resources.0].aux_file_presence.stat.exists
28 and not aux_resources_data_check.stat.exists
29
30 rescue:
31 - name: Removing the resources data due to an error - so the next run can try again
32 command: /bin/false
33 register: upload_failed
34
35 always:
36 - name: unmount resource dir
37 mount:
38 path: /tmp/resource_data
39 src: "{{ hostvars[groups.resources.0].ansible_host }}:{{hostvars[groups.resources.0].resources_dir }}"
40 fstype: nfs
41 state: absent
42
43 - name: Remove the resource data on error
44 file:
45 path: "{{ app_data_path }}"
46 state: absent
47 when: upload_failed is defined
48
49 - name: Remove the auxilliary resource data on error
50 file:
51 path: "{{ aux_data_path }}"
52 state: absent
53 when: upload_failed is defined