summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/tasks/template.yml
blob: 87e45a6caab4f1fc659f8db5fd1a3b5c74592705 (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
- name: "Populate template '{{ tmpl_name }}' in project '{{ kaas_project }}' for application '{{ appname | default('kaas') }}'"
  template: src="{{ item }}" dest="{{ kaas_template_path }}/{{ dest_name }}" owner=root group=root mode="0644"
  register: result
  vars:
    default_name: "{{ item | basename | regex_replace('\\.j2','') }}"
    dest_name: "{{ (appname is defined) | ternary ( '90-' + (appname | default('')) + '.yml', default_name ) }}"
  with_first_found:
    - paths:
        - "{{ role_path }}/templates/"
        - "{{ kaas_project_path }}/templates/"
      files:
        - "{{ tmpl_name }}"

- name: "Configure KaaS resources defined in {{ tmpl_name }}"
  include_role: name="openshift_resource"
  when: instantiate == true
  vars: 
    default_name: "{{ tmpl_name | basename | regex_replace('\\.j2','') }}"
    dest_name: "{{ (appname is defined) | ternary ( '90-' + (appname | default('')) + '.yml', default_name ) }}"
    template: "{{ dest_name }}"
    template_path: "{{ kaas_template_path }}"
    project: "{{ kaas_project }}"
    recreate: "{{ result | changed | ternary (delete | ternary(true, false), false) }}"
    replace: "{{ result | changed | ternary (delete | ternary(false, true), false) }}"

# alternatively load template
# TODO