summaryrefslogtreecommitdiffstats
path: root/ansible/roles/resource-data/tasks/main.yml
blob: 023a160e28181bb0c49c0b855b59de64c8b2f1e0 (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
32
33
34
35
36
37
38
39
40
41
42
43
---
- name: Collect source resources
  block:
    - name: Check if source dir and files are present
      stat:
        path: "{{ item.source_dir }}/{{ item.source_filename }}"
        get_checksum: false
      loop:
        - { 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_filename,
            'destination_dir': item.item.target_dir } ] }}"
      loop: "{{ source_path.results }}"
      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"
  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