Michal Ptacek | f590720 | 2018-12-19 11:54:34 +0000 | [diff] [blame] | 1 | --- |
Samuli Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 2 | - name: Collect source resources |
| 3 | block: |
| 4 | - name: Check if source dir and files are present |
| 5 | stat: |
Samuli Silvius | 182f5a4 | 2019-03-26 17:30:48 +0200 | [diff] [blame] | 6 | path: "{{ item.source_dir }}/{{ item.source_filename }}" |
Samuli Silvius | 178ff1e | 2019-03-07 11:49:20 +0200 | [diff] [blame] | 7 | get_checksum: false |
Samuli Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 8 | loop: |
Samuli Silvius | 182f5a4 | 2019-03-26 17:30:48 +0200 | [diff] [blame] | 9 | - { 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 Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 18 | register: source_path |
Samuli Silvius | 182f5a4 | 2019-03-26 17:30:48 +0200 | [diff] [blame] | 19 | 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 Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 24 | |
| 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 Silvius | 182f5a4 | 2019-03-26 17:30:48 +0200 | [diff] [blame] | 29 | {'file': item.item.target_filename, |
| 30 | 'destination_dir': item.item.target_dir } ] }}" |
Samuli Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 31 | loop: "{{ source_path.results }}" |
Samuli Silvius | 182f5a4 | 2019-03-26 17:30:48 +0200 | [diff] [blame] | 32 | when: item.stat is defined |
| 33 | failed_when: not item.stat.exists |
Samuli Silvius | 29886f0 | 2019-02-19 16:00:37 +0200 | [diff] [blame] | 34 | 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 |