summaryrefslogtreecommitdiffstats
path: root/roles/openshift_resource/tasks/main.yml
blob: 5dcc894c271627ab753e8cb6238aafc1c990432f (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
---
- block:
  - name: "Read template {{ template }}"
    command: cat '{{template_path}}/{{template}}'
    changed_when: false
    register: results

  - name: "Parse JSON templates {{ template }}"
    set_fact: tmpl="{{ results.stdout | from_json }}"
    when: template.find(".json") != -1

  - name: "Parse YaML templates {{ template }}"
    set_fact: tmpl="{{ results.stdout | from_yaml }}"
    when: template.find(".json") == -1

  - name: "Populating resources defined in {{ template }} template"
    include_tasks: template.yml
    register: results
    vars:
      metadata:    "{{ tmpl.metadata | default({}) }}"
      annotations: "{{ metadata.annotations | default({}) }}"
      strategy:    "{{ instantiate | default(true) | ternary (annotations['kaas/strategy'] | default('auto'), 'manual') }}"
    when: 
      - tmpl.kind == "Template"
      - strategy == "auto"

# With results it populates empty templates....    
  - name: "Creating template/resources defined in {{ template }}"
    include_tasks: resource.yml
    vars:
      metadata:    "{{ tmpl.metadata | default({}) }}"
      annotations: "{{ metadata.annotations | default({}) }}"
      strategy:    "{{ instantiate | default(true) | ternary (annotations['kaas/strategy'] | default('auto'), 'manual') }}"
    when: (tmpl.kind != "Template") or (strategy != "auto")
#    when: results | skipped

  run_once: true