diff options
author | Samuli Silvius <s.silvius@partner.samsung.com> | 2019-03-26 17:30:48 +0200 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2019-03-26 15:38:37 +0000 |
commit | 182f5a4ff654d6b1cf73e4501d14bb97c2bd16d3 (patch) | |
tree | 32250e5d3e56cfb02b9d85047b48e46a9614d953 /ansible/roles/resource-data | |
parent | 98ea82804e23245082f2a7b9363ea5b10300329a (diff) |
Wrong filename does not fail transfer
User typo on resource package filename or dir does not cause install to fail
but just skips that resource package.
Change resource paths handling to skip resource only if
variable is not defined or empty, but if a value is given
resource must exist or transfer fails otherwise.
Issue-ID: OOM-1736
Change-Id: I765c5dc8eb5e58875f032e056f9a8360aee702c0
Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com>
Diffstat (limited to 'ansible/roles/resource-data')
-rw-r--r-- | ansible/roles/resource-data/tasks/main.yml | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/ansible/roles/resource-data/tasks/main.yml b/ansible/roles/resource-data/tasks/main.yml index 41046d81..023a160e 100644 --- a/ansible/roles/resource-data/tasks/main.yml +++ b/ansible/roles/resource-data/tasks/main.yml @@ -3,23 +3,34 @@ block: - name: Check if source dir and files are present stat: - path: "{{ item.source }}" + path: "{{ item.source_dir }}/{{ item.source_filename }}" get_checksum: false 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) }}" } + - { source_dir: "{{ resources_dir | default('', true) }}", + source_filename: "{{ resources_filename | default('', true) }}", + target_dir: "{{ app_data_path | default('', true) }}", + target_filename: "{{ resources_filename | default('', true) }}" } + + - { source_dir: "{{ resources_dir | default('', true) }}", + source_filename: "{{ aux_resources_filename | default('', true) }}", + target_dir: "{{ aux_data_path | default('', true) }}", + target_filename: "{{ aux_resources_filename | default('', true) }}" } register: source_path + when: + - item.source_dir | length > 0 + - item.source_filename | length > 0 + - item.target_dir | length > 0 + - item.target_filename | length > 0 - 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 } ] }}" + {'file': item.item.target_filename, + 'destination_dir': item.item.target_dir } ] }}" loop: "{{ source_path.results }}" - when: item.stat.exists + when: item.stat is defined + failed_when: not item.stat.exists when: inventory_hostname in groups.resources - name: "Upload resource files {{ hostvars[groups.resources.0].to_be_uploaded_resources_list }} to infrastructure" |