blob: 023a160e28181bb0c49c0b855b59de64c8b2f1e0 [file] [log] [blame]
Michal Ptacekf5907202018-12-19 11:54:34 +00001---
Samuli Silvius29886f02019-02-19 16:00:37 +02002- name: Collect source resources
3 block:
4 - name: Check if source dir and files are present
5 stat:
Samuli Silvius182f5a42019-03-26 17:30:48 +02006 path: "{{ item.source_dir }}/{{ item.source_filename }}"
Samuli Silvius178ff1e2019-03-07 11:49:20 +02007 get_checksum: false
Samuli Silvius29886f02019-02-19 16:00:37 +02008 loop:
Samuli Silvius182f5a42019-03-26 17:30:48 +02009 - { source_dir: "{{ resources_dir | default('', true) }}",
10 source_filename: "{{ resources_filename | default('', true) }}",
11 target_dir: "{{ app_data_path | default('', true) }}",
12 target_filename: "{{ resources_filename | default('', true) }}" }
13
14 - { source_dir: "{{ resources_dir | default('', true) }}",
15 source_filename: "{{ aux_resources_filename | default('', true) }}",
16 target_dir: "{{ aux_data_path | default('', true) }}",
17 target_filename: "{{ aux_resources_filename | default('', true) }}" }
Samuli Silvius29886f02019-02-19 16:00:37 +020018 register: source_path
Samuli Silvius182f5a42019-03-26 17:30:48 +020019 when:
20 - item.source_dir | length > 0
21 - item.source_filename | length > 0
22 - item.target_dir | length > 0
23 - item.target_filename | length > 0
Samuli Silvius29886f02019-02-19 16:00:37 +020024
25 - name: Create initial resources list of dicts
26 set_fact:
27 to_be_uploaded_resources_list: "{{
28 to_be_uploaded_resources_list | default([]) + [
Samuli Silvius182f5a42019-03-26 17:30:48 +020029 {'file': item.item.target_filename,
30 'destination_dir': item.item.target_dir } ] }}"
Samuli Silvius29886f02019-02-19 16:00:37 +020031 loop: "{{ source_path.results }}"
Samuli Silvius182f5a42019-03-26 17:30:48 +020032 when: item.stat is defined
33 failed_when: not item.stat.exists
Samuli Silvius29886f02019-02-19 16:00:37 +020034 when: inventory_hostname in groups.resources
35
36- name: "Upload resource files {{ hostvars[groups.resources.0].to_be_uploaded_resources_list }} to infrastructure"
37 include_tasks: upload_resources.yml
38 vars:
39 resources_source_host: "{{ hostvars[groups.resources.0].ansible_host | default(hostvars[groups.resources.0].inventory_hostname) }}"
40 resources_list_of_dicts: "{{ hostvars[groups.resources.0].to_be_uploaded_resources_list }}"
41 when:
42 - inventory_hostname in groups.infrastructure
43 - hostvars[groups.resources.0].to_be_uploaded_resources_list is defined