summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/tasks/templates.yml
blob: 86f0d4a4d19cb7e024dd351b2783ef4c247ca0eb (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
---
# Sorting is not enforeced
- name: "Find KaaS templates"
  command: "echo {{ item | quote }}"
  register: results
  changed_when: false
  when: not (item | regex_search('kaas-app')) or ((kaas_project_pods | length > 0) and (item | regex_search('kaas-app-pods'))) or ((kaas_project_builders | length > 0) and (item | regex_search('kaas-app-builders')))
  with_fileglob:
    - "{{ role_path }}/templates/{{ kaas_template_glob | default('*') }}.j2"
    - "{{ kaas_project_path }}/templates/{{ kaas_template_glob | default('*') }}.j2"


#- debug: msg="{{ results }}"

- name: "Sort and execute KaaS templates"
  include_tasks: "template.yml"
#  delegate_to: "{{ groups.masters[0] }}"
  run_once: true
  with_items: "{{ sorted_tmpl }}"
  vars:
    sorted_tmpl: "{{ (results.results[0] is defined) | ternary (results | json_query('results[*].stdout_lines') | sum(start=[]) | map('basename') | sort | unique, []) }}"
    instantiate: true
    load: false
    pods: "{{ kaas_project_pods }}"
    builders: "{{ kaas_project_builders }}"
    parameters: "{{ kaas_project_parameters }}"
  loop_control:
    loop_var: tmpl_name