blob: bcdc7dd13c5fbf2850a65a327f175ba07a2977e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
---
- 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
|