Guillaume Coré
2020-03-11 1d970fbaa4bd88c9d094d9587db59fdf9cd0239a
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
38
39
40
41
42
43
---
# Everything else should use this going forward, combined with a specific set of tasks called by main.yml
# to configure the template creation for the specific cloud provider
- name: Check if master template exists for the environment
  stat:
    path: "../configs/{{ env_type }}/files/cloud_providers/{{cloud_provider}}_cloud_template_master.j2"
  register: stat_master_template
 
- name: Use master template from the environment
  set_fact:
    cloud_infra_master_template_src: "../configs/{{ env_type }}/files/cloud_providers/{{cloud_provider}}_cloud_template_master.j2"
  when: stat_master_template.stat.exists
 
- name: Check if nested template exists for the environment
  stat:
    path: "../configs/{{ env_type }}/files/cloud_providers/{{cloud_provider}}_cloud_template_nested.j2"
  register: stat_nested_template
 
- name: Use nested template from the environment
  set_fact:
    cloud_infra_nested_template_src: "../configs/{{ env_type }}/files/cloud_providers/{{cloud_provider}}_cloud_template_nested.j2"
  when: stat_nested_template.stat.exists
 
- name: Use the default infra template
  set_fact:
    cloud_infra_master_template_src: "templates/cloud_template_master.j2"
  when: not stat_master_template.stat.exists
 
- name: Check if default nested template exists
  stat:
    path: "templates/cloud_template_nested.j2"
  register: stat_default_nested_template
 
- name: Use the default infra template
  set_fact:
    cloud_infra_nested_template_src: "templates/cloud_template_nested.j2"
  when:
    - not stat_nested_template.stat.exists
    - stat_default_nested_template.stat.exists
 
- name: Print cloud_infra_template_src
  debug:
    var: cloud_infra_master_template_src