summaryrefslogtreecommitdiffstats
path: root/ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml
diff options
context:
space:
mode:
authorSamuli Silvius <s.silvius@partner.samsung.com>2019-02-19 16:00:37 +0200
committerMichal Ptacek <m.ptacek@partner.samsung.com>2019-03-07 08:01:08 +0000
commit29886f09d53bee1ecdc1bc8612e8edb4a130a270 (patch)
tree9507ee70a95e27afd81adf284f1dfe2c8b946491 /ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml
parentf968e170316ee1e514d4cf03a56137ba93c1a0bf (diff)
Re-factored resources upload into role
Whole functionality of resource files upload is implemented in resource-data role instead of playbook level tasks. This will make roles easier to test and make it easier to implement other OS support later. Issue-ID: OOM-1654 Change-Id: I3d3da9381b0e804f511ee854c41554b924d18883 Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com>
Diffstat (limited to 'ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml')
-rw-r--r--ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml34
1 files changed, 34 insertions, 0 deletions
diff --git a/ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml b/ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml
new file mode 100644
index 00000000..9baca2fe
--- /dev/null
+++ b/ansible/roles/resource-data/tasks/unarchive-nfs-resource.yml
@@ -0,0 +1,34 @@
+---
+#
+# Expected variables
+# resources_source_host
+# resources_dir
+# resource_source_filename
+# resource_destination_directory
+# Output is upload_failed true/false
+#
+- name: "Upload resource {{ resources_dir }}/{{ resource_source_filename }} to infrastructure servers over nfs"
+ block:
+ - name: Mount resource dir
+ mount:
+ path: /tmp/resource_data
+ src: "{{ resources_source_host }}:{{ resources_dir }}"
+ fstype: nfs
+ state: mounted
+
+ - name: "Unarchive resource {{ resources_dir }}/{{ resource_source_filename }} to {{ resource_destination_directory }} dir on infrastructure servers over nfs"
+ unarchive:
+ src: "/tmp/resource_data/{{ resource_source_filename }}"
+ dest: "{{ resource_destination_directory }}"
+ remote_src: yes
+ rescue:
+ - name: Upload failed
+ set_fact:
+ upload_failed: true
+ always:
+ - name: Unmount resource dir
+ mount:
+ path: /tmp/resource_data
+ src: "{{ resources_source_host }}:{{ resources_dir }}"
+ fstype: nfs
+ state: absent