-
Notifications
You must be signed in to change notification settings - Fork 1
/
ccvgd.yml
213 lines (180 loc) · 5.75 KB
/
ccvgd.yml
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
- name: CCVGD deployment
remote_user: ulsprovision
hosts: ccvgd
become: yes
tasks:
- name: Include host vars
include_vars:
file: hostvars/{{inventory_hostname}}.config.yml
name: configvars
- name: host directory
file:
path: /opt/local/ccvgd
state: directory
mode: '2775'
owner: root
group: ulssysdev
- name: database loader directory
file:
path: /opt/local/ccvgd/dataload
state: directory
mode: '2775'
owner: root
group: ulssysdev
- name: frontend directory
file:
path: /opt/local/ccvgd/frontend
state: directory
mode: '2775'
owner: root
group: ulssysdev
- name: backend directory
file:
path: /opt/local/ccvgd/backend
state: directory
mode: '2775'
owner: root
group: ulssysdev
- name: Clone database loader from git
git:
repo: https://github.com/ulsdevteam/ccvgd-database.git
dest: /opt/local/ccvgd/dataload
force: yes
umask: '0002'
- name: Clone frontend from git
git:
repo: https://github.com/ulsdevteam/ccvgd-frontend.git
dest: /opt/local/ccvgd/frontend
force: yes
umask: '0002'
- name: Clone backend from git
git:
repo: https://github.com/ulsdevteam/ccvgd-backend.git
dest: /opt/local/ccvgd/backend
force: yes
umask: '0002'
version: rhel7-python36
- name: Python requirements file only works if wheel is installed
pip:
executable: /opt/rh/rh-python36/root/usr/bin/pip
name: wheel
- name: Python requirements file only works if pip is updated
pip:
executable: /opt/rh/rh-python36/root/usr/bin/pip
name: pip
extra_args: --upgrade
- name: Install python requirements per application
pip:
executable: /opt/rh/rh-python36/root/usr/bin/pip
requirements: /opt/local/ccvgd/backend/requirements.txt
- name: Deploy config.txt file for database tooling
copy:
src: resources/ccvgd/config.txt.template
dest: /opt/local/ccvgd/dataload/pythonScript/config.txt
- name: set hostname in config.txt
replace:
path: /opt/local/ccvgd/dataload/pythonScript/config.txt
regexp: 'MYSQLHOST'
replace: 'localhost'
- name: set databasename in config.txt
replace:
path: /opt/local/ccvgd/dataload/pythonScript/config.txt
regexp: 'MYSQLDATA'
replace: '{{configvars.database.name}}'
- name: set username in config.txt
replace:
path: /opt/local/ccvgd/dataload/pythonScript/config.txt
regexp: 'MYSQLUSER'
replace: '{{configvars.database.username}}'
- name: set password in config.txt
replace:
path: /opt/local/ccvgd/dataload/pythonScript/config.txt
regexp: 'MYSQLPASS'
replace: '{{configvars.database.password}}'
- name: set hostname in config.py
lineinfile:
path: /opt/local/ccvgd/backend/config.py
state: present
regexp: 'mysql_host = '
line: 'mysql_host = "localhost"'
- name: set username in config.py
lineinfile:
path: /opt/local/ccvgd/backend/config.py
state: present
regexp: 'mysql_username = '
line: 'mysql_username = "{{configvars.database.username}}"'
- name: set password in config.py
lineinfile:
path: /opt/local/ccvgd/backend/config.py
state: present
regexp: 'mysql_password = '
line: 'mysql_password = "{{configvars.database.password}}"'
- name: set database in config.py
lineinfile:
path: /opt/local/ccvgd/backend/config.py
state: present
regexp: 'mysql_database = '
line: 'mysql_database = "{{configvars.database.name}}"'
- name: create database
mysql_db:
name: '{{configvars.database.name}}'
- name: grant database permissions
mysql_user:
name: '{{configvars.database.name}}'
password: '{{configvars.database.password}}'
priv: '{{configvars.database.username}}.*:ALL'
state: present
- name: create certificate directory
file:
path: /etc/pki/tls/certs/{{configvars.site.hostname}}/
state: directory
- name: create certificate private directory
file:
path: /etc/pki/tls/private/{{configvars.site.hostname}}/
state: directory
- name: copy temporary certificate
copy:
src: /etc/pki/tls/certs/localhost.crt
dest: /etc/pki/tls/certs/{{configvars.site.hostname}}/cert.pem
remote_src: yes
owner: root
group: ulssysdev
mode: preserve
force: no
register: certfile_changed
- name: copy temporary private key
copy:
src: /etc/pki/tls/private/localhost.key
dest: /etc/pki/tls/private/{{configvars.site.hostname}}/privkey.pem
remote_src: yes
owner: root
group: ulssysdev
mode: preserve
force: no
register: certchain_changed
- name: Deploy vhost
copy:
src: resources/ccvgd/vhost.conf.template
dest: /etc/httpd/conf.d/{{configvars.site.hostname}}.conf
- name: disable certificate chain in vhost
lineinfile:
path: /etc/httpd/conf.d/{{configvars.site.hostname}}.conf
regexp: '^(\s*SSLCertificateChainFile.*$)'
line: '#\1'
backrefs: yes
when: certfile_changed is succeeded or certchain_changed is succeeded
- name: set hostname in vhost
replace:
path: /etc/httpd/conf.d/{{configvars.site.hostname}}.conf
regexp: 'SERVERNAME'
replace: '{{configvars.site.hostname}}'
- name: set backend port in vhost
replace:
path: /etc/httpd/conf.d/{{configvars.site.hostname}}.conf
regexp: 'PROXYPORT'
replace: '{{configvars.site.backend_port}}'
- name: set backend endpoint in vhost
replace:
path: /etc/httpd/conf.d/{{configvars.site.hostname}}.conf
regexp: 'PROXYENDPOINT'
replace: '{{configvars.site.backend_uri}}'