blob: 3325ee4a73927b705b8163d3bb813855f47ea267 (
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
---
######################################################################
# Users, projects, and privileges
- name: Ensure the CFME user exists
oc_user:
state: present
username: "{{ openshift_cfme_user }}"
- name: Ensure the CFME namespace exists with CFME user as admin
oc_project:
state: present
name: "{{ openshift_cfme_project }}"
display_name: "{{ openshift_cfme_project_description }}"
admin: "{{ openshift_cfme_user }}"
- name: Ensure the CFME namespace service account is privileged
oc_adm_policy_user:
namespace: "{{ openshift_cfme_project }}"
user: "{{ openshift_cfme_service_account }}"
resource_kind: scc
resource_name: privileged
state: present
######################################################################
# NFS
- name: Ensure the /exports/ directory exists
file:
path: /exports/
state: directory
mode: 0755
owner: root
group: root
- name: Ensure the miq-pv0X export directories exist
file:
path: "/exports/{{ item }}"
state: directory
mode: 0775
owner: root
group: root
with_items: "{{ openshift_cfme_pv_exports }}"
- name: Ensure the NFS exports for CFME PVs exist
copy:
src: openshift_cfme.exports
dest: /etc/exports.d/openshift_cfme.exports
register: nfs_exports_updated
- name: Ensure the NFS export table is refreshed if exports were added
command: exportfs -ar
when:
- nfs_exports_updated.changed
######################################################################
# Create the required CFME PVs. Check out these online docs if you
# need a refresher on includes looping with items:
# * http://docs.ansible.com/ansible/playbooks_loops.html#loops-and-includes-in-2-0
# * http://stackoverflow.com/a/35128533
#
# TODO: Handle the case where a PV template is updated in
# openshift-ansible and the change needs to be landed on the managed
# cluster.
- include: create_pvs.yml
with_items: "{{ openshift_cfme_pv_data }}"
######################################################################
# CFME App Template
#
# Note, this is different from the create_pvs.yml tasks in that the
# application template does not require any jinja2 evaluation.
#
# TODO: Handle the case where the server template is updated in
# openshift-ansible and the change needs to be landed on the managed
# cluster.
- name: Check if the CFME Server template has been created already
oc_obj:
namespace: "{{ openshift_cfme_project }}"
state: list
kind: template
name: manageiq
register: miq_server_check
- name: Copy over CFME Server template
copy:
src: miq-template.yaml
dest: "{{ template_dir }}/miq-template.yaml"
- name: Ensure the server template was read from disk
debug:
var=r_openshift_cfme_miq_template_content
- name: Ensure CFME Server Template exists
oc_obj:
namespace: "{{ openshift_cfme_project }}"
kind: template
name: "manageiq"
state: present
content: "{{ r_openshift_cfme_miq_template_content }}"
######################################################################
# Let's do this
- name: Ensure the CFME Server is created
oc_process:
namespace: "{{ openshift_cfme_project }}"
template_name: manageiq
create: True
params:
APPLICATION_IMG_NAME: "{{ openshift_cfme_application_img_name }}"
POSTGRESQL_IMG_NAME: "{{ openshift_cfme_postgresql_img_name }}"
MEMCACHED_IMG_NAME: "{{ openshift_cfme_memcached_img_name }}"
APPLICATION_IMG_TAG: "{{ openshift_cfme_application_img_tag }}"
POSTGRESQL_IMG_TAG: "{{ openshift_cfme_postgresql_img_tag }}"
MEMCACHED_IMG_TAG: "{{ openshift_cfme_memcached_img_tag }}"
register: cfme_new_app_process
run_once: True
when:
# User said to install CFME in their inventory
- openshift_cfme_install_app | bool
# # The server app doesn't exist already
# - not miq_server_check.results.results.0
- debug:
var: cfme_new_app_process
######################################################################
# Various cleanup steps
# TODO: Not sure what to do about this right now. Might be able to
# just delete it? This currently warns about "Unable to find
# '<TEMP_DIR>' in expected paths."
- name: Ensure the temporary PV/App templates are erased
file:
path: "{{ item }}"
state: absent
with_fileglob:
- "{{ template_dir }}/*.yaml"
- name: Ensure the temporary PV/app template directory is erased
file:
path: "{{ template_dir }}"
state: absent
######################################################################
- name: Status update
debug:
msg: >
CFME has been deployed. Note that there will be a delay before
it is fully initialized.
|