summaryrefslogtreecommitdiffstats
path: root/ansible/roles/resource-data/tasks/main.yml
blob: 41046d81f1d1652d6e3965c76cd858b337bebba7 (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
---
- name: Collect source resources
  block:
    - name: Check if source dir and files are present
      stat:
        path: "{{ item.source }}"
        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) }}" }
      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