summaryrefslogtreecommitdiffstats
path: root/ansible/roles/resource-data/tasks/main.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/main.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/main.yml')
-rw-r--r--ansible/roles/resource-data/tasks/main.yml31
1 files changed, 30 insertions, 1 deletions
diff --git a/ansible/roles/resource-data/tasks/main.yml b/ansible/roles/resource-data/tasks/main.yml
index 51127226..bcdc7dd1 100644
--- a/ansible/roles/resource-data/tasks/main.yml
+++ b/ansible/roles/resource-data/tasks/main.yml
@@ -1,2 +1,31 @@
---
-- include_tasks: "{{ transport }}-upload.yml"
+- name: Collect source resources
+ block:
+ - name: Check if source dir and files are present
+ stat:
+ path: "{{ item.source }}"
+ loop:
+ - { source: "{{ resources_dir }}/{{ resources_filename | default('thisdoesnotexists', true) }}",
+ target: "{{ app_data_path }}/{{ resources_filename | default('thisdoesnotexists', true) }}" }
+ - { source: "{{ resources_dir }}/{{ aux_resources_filename | default('thisdoesnotexists', true) }}",
+ target: "{{ aux_data_path }}/{{ aux_resources_filename | default('thisdoesnotexists', true) }}" }
+ register: source_path
+
+ - name: Create initial resources list of dicts
+ set_fact:
+ to_be_uploaded_resources_list: "{{
+ to_be_uploaded_resources_list | default([]) + [
+ {'file': item.item.target | basename,
+ 'destination_dir': item.item.target | dirname } ] }}"
+ loop: "{{ source_path.results }}"
+ when: item.stat.exists
+ when: inventory_hostname in groups.resources
+
+- name: "Upload resource files {{ hostvars[groups.resources.0].to_be_uploaded_resources_list }} to infrastructure"
+ include_tasks: upload_resources.yml
+ vars:
+ resources_source_host: "{{ hostvars[groups.resources.0].ansible_host | default(hostvars[groups.resources.0].inventory_hostname) }}"
+ resources_list_of_dicts: "{{ hostvars[groups.resources.0].to_be_uploaded_resources_list }}"
+ when:
+ - inventory_hostname in groups.infrastructure
+ - hostvars[groups.resources.0].to_be_uploaded_resources_list is defined