summaryrefslogtreecommitdiffstats
path: root/roles/openshift_management/tasks/template.yml
blob: f40af73495960bc2510773d729d2dd2dcf388fea (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
# Tasks for ensuring the correct CFME templates are landed on the remote system

######################################################################
# CFME App Template
#
# Note, this is different from the create_nfs_pvs.yml tasks in that
# the application template does not require any jinja2 evaluation.
#
# TODO: Handle the case where the server or PV templates are updated
# in openshift-ansible and the change needs to be landed on the
# managed cluster.

######################################################################
# STANDARD PODIFIED DATABASE TEMPLATE
- when: not __openshift_management_use_ext_db
  block:
  - name: Check if the Management Server template has been created already
    oc_obj:
      namespace: "{{ openshift_management_project }}"
      state: list
      kind: template
      name: "{{ __openshift_management_flavor }}"
    register: miq_server_check

  - when: miq_server_check.results.results == [{}]
    block:
    - name: Copy over Management Server template
      copy:
        src: "templates/{{ __openshift_management_flavor }}/{{ __openshift_management_flavor_short }}-template.yaml"
        dest: "{{ template_dir }}/"

    - name: Ensure Management Server Template is created
      oc_obj:
        namespace: "{{ openshift_management_project }}"
        name: "{{ __openshift_management_flavor }}"
        state: present
        kind: template
        files:
        - "{{ template_dir }}/{{ __openshift_management_flavor_short }}-template.yaml"

######################################################################
# EXTERNAL DATABASE TEMPLATE
- when: __openshift_management_use_ext_db
  block:
  - name: Check if the Management Ext-DB Server template has been created already
    oc_obj:
      namespace: "{{ openshift_management_project }}"
      state: list
      kind: template
      name: "{{ __openshift_management_flavor }}-ext-db"
    register: miq_ext_db_server_check

  - when: miq_ext_db_server_check.results.results == [{}]
    block:
    - name: Copy over Management Ext-DB Server template
      copy:
        src: "templates/{{ __openshift_management_flavor }}/{{__openshift_management_flavor_short}}-template-ext-db.yaml"
        dest: "{{ template_dir }}/"

    - name: Ensure Management Ext-DB Server Template is created
      oc_obj:
        namespace: "{{ openshift_management_project }}"
        name: "{{ __openshift_management_flavor }}-ext-db"
        state: present
        kind: template
        files:
        - "{{ template_dir }}/{{ __openshift_management_flavor_short }}-template-ext-db.yaml"

# End app template creation.
######################################################################

######################################################################
# Begin conditional PV template creations

# Required for the application server
- name: Check if the Management App PV template has been created already
  oc_obj:
    namespace: "{{ openshift_management_project }}"
    state: list
    kind: template
    name: "{{ __openshift_management_flavor }}-app-pv"
  register: miq_app_pv_check

- when: miq_app_pv_check.results.results == [{}]
  block:
  - name: Copy over Management App PV template
    copy:
      src: "templates/{{ __openshift_management_flavor }}/{{ __openshift_management_flavor_short }}-pv-server-example.yaml"
      dest: "{{ template_dir }}/"

  - name: Ensure Management App PV Template is created
    oc_obj:
      namespace: "{{ openshift_management_project }}"
      name: "{{ __openshift_management_flavor }}-app-pv"
      state: present
      kind: template
      files:
      - "{{ template_dir }}/{{ __openshift_management_flavor_short }}-pv-server-example.yaml"

#---------------------------------------------------------------------

# Required for database if the installation is fully podified
- when: not __openshift_management_use_ext_db
  block:
  - name: Check if the Management DB PV template has been created already
    oc_obj:
      namespace: "{{ openshift_management_project }}"
      state: list
      kind: template
      name: "{{ __openshift_management_flavor }}-db-pv"
    register: miq_db_pv_check

  - when: miq_db_pv_check.results.results == [{}]
    block:
    - name: Copy over Management DB PV template
      copy:
        src: "templates/{{ __openshift_management_flavor }}/{{ __openshift_management_flavor_short }}-pv-db-example.yaml"
        dest: "{{ template_dir }}/"

    - name: Ensure Management DB PV Template is created
      oc_obj:
        namespace: "{{ openshift_management_project }}"
        name: "{{ __openshift_management_flavor }}-db-pv"
        state: present
        kind: template
        files:
        - "{{ template_dir }}/{{ __openshift_management_flavor_short }}-pv-db-example.yaml"