bcdc7dd13c5fbf2850a65a327f175ba07a2977e1
[oom/offline-installer.git] / ansible / roles / resource-data / tasks / main.yml
1 ---
2 - name: Collect source resources
3   block:
4     - name: Check if source dir and files are present
5       stat:
6         path: "{{ item.source }}"
7       loop:
8         - { source: "{{ resources_dir }}/{{ resources_filename | default('thisdoesnotexists', true) }}",
9             target: "{{ app_data_path }}/{{ resources_filename | default('thisdoesnotexists', true) }}" }
10         - { source: "{{ resources_dir }}/{{ aux_resources_filename | default('thisdoesnotexists', true) }}",
11             target: "{{ aux_data_path }}/{{ aux_resources_filename | default('thisdoesnotexists', true) }}" }
12       register: source_path
13
14     - name: Create initial resources list of dicts
15       set_fact:
16         to_be_uploaded_resources_list: "{{
17             to_be_uploaded_resources_list | default([]) + [
18             {'file': item.item.target | basename,
19             'destination_dir': item.item.target | dirname } ] }}"
20       loop: "{{ source_path.results }}"
21       when: item.stat.exists
22   when: inventory_hostname in groups.resources
23
24 - name: "Upload resource files {{ hostvars[groups.resources.0].to_be_uploaded_resources_list }} to infrastructure"
25   include_tasks: upload_resources.yml
26   vars:
27     resources_source_host: "{{ hostvars[groups.resources.0].ansible_host | default(hostvars[groups.resources.0].inventory_hostname) }}"
28     resources_list_of_dicts: "{{ hostvars[groups.resources.0].to_be_uploaded_resources_list }}"
29   when:
30     - inventory_hostname in groups.infrastructure
31     - hostvars[groups.resources.0].to_be_uploaded_resources_list is defined