blob: 9bd83e8544d11d3ea38cb29fe53391d3c58f021c [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2/**
3 * Orchestration functions
4 *
5*/
6
7def validateFoundationInfra(master) {
8 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +02009
10 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['salt-key'], null, true)
11 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version', [], null, true)
12 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true)
13 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory', [], null, true)
14 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top', [], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +010015}
16
Jakub Josef79ecec32017-02-17 14:36:28 +010017def installFoundationInfra(master) {
18 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020019
Petr Michalecde0ff322017-10-04 09:32:14 +020020 salt.enforceState(master, 'I@salt:master', ['salt.master', 'reclass'], true, false, null, false, 120, 2)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020021
22 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
23 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
24
25 salt.enforceState(master, 'I@salt:master', ['linux.system'], true)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030026 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020027 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true)
28
Jakub Josef200550f2017-05-16 17:39:55 +020029 salt.enforceState(master, '*', ['linux.system'], true)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030030 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'], true)
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020031 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020032 sleep(5)
33 salt.enforceState(master, '*', ['linux.network.host'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010034}
35
Jiri Broulik976bf6c2017-10-20 14:43:25 +020036def installFoundationInfraOnTarget(master, target) {
37 def salt = new com.mirantis.mk.Salt()
38
39 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
40
41 salt.runSaltProcessStep(master, target, 'saltutil.refresh_pillar', [], null, true)
42 salt.runSaltProcessStep(master, target, 'saltutil.sync_all', [], null, true)
43
44 salt.enforceState(master, target, ['linux.system'], true)
45 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
46 salt.enforceState(master, target, ['salt.minion'], true)
47
48 salt.enforceState(master, target, ['linux', 'openssh', 'ntp'], true)
49 sleep(5)
50 salt.enforceState(master, target, ['linux.network.host'], true)
51}
52
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010053def installInfraKvm(master) {
54 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010055
Ales Komarekef2bab62017-04-26 11:48:28 +020056 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
57 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
58
Richard Felkl286f25f2017-07-26 14:23:55 +020059 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030060 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010061 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
62 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010063
Ales Komarekef2bab62017-04-26 11:48:28 +020064 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010065
Marek Celoudc9b3cc82017-05-22 12:50:53 +000066 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true)
67 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010068}
Jakub Josef79ecec32017-02-17 14:36:28 +010069
vrovachev1c4770b2017-07-05 13:25:21 +040070def installInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010071 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020072
Jakub Josef79ecec32017-02-17 14:36:28 +010073 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020074 if (salt.testTarget(master, 'I@glusterfs:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +040075 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010076
vrovachev1c4770b2017-07-05 13:25:21 +040077 withEnv(['ASK_ON_ERROR=false']){
78 retry(5) {
79 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
80 }
Alexander Noskov93acac42017-06-20 17:55:55 +020081 }
vrovachev1c4770b2017-07-05 13:25:21 +040082
83 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
84 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Alexander Noskov93acac42017-06-20 17:55:55 +020085 }
Ales Komarekef2bab62017-04-26 11:48:28 +020086
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030087 // Ensure glusterfs clusters is ready
88 if (salt.testTarget(master, 'I@glusterfs:client')) {
89 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
90 }
91
Jakub Josef79ecec32017-02-17 14:36:28 +010092 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +020093 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
vrovachev1c4770b2017-07-05 13:25:21 +040094 withEnv(['ASK_ON_ERROR=false']){
95 retry(2) {
96 salt.enforceState(master, 'I@galera:master', 'galera', true)
97 }
Ales Komarekef2bab62017-04-26 11:48:28 +020098 }
vrovachev1c4770b2017-07-05 13:25:21 +040099 salt.enforceState(master, 'I@galera:slave', 'galera', true)
100
101 // Check galera status
102 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
103 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300104 // If galera is not enabled check if we need to install mysql:server
105 } else if (salt.testTarget(master, 'I@mysql:server')){
106 salt.enforceState(master, 'I@mysql:server', 'mysql.server', true)
107 if (salt.testTarget(master, 'I@mysql:client')){
108 salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
109 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200110 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200111
vrovachev1c4770b2017-07-05 13:25:21 +0400112 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200113 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400114 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200115 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400116 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200117
vrovachev1c4770b2017-07-05 13:25:21 +0400118 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200119 if (salt.testTarget(master, 'I@keepalived:cluster')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400120 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
121 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
122 }
123
124 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200125 if (salt.testTarget(master, 'I@rabbitmq:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400126 withEnv(['ASK_ON_ERROR=false']){
127 retry(2) {
128 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
129 }
130 }
131
132 // Check the rabbitmq status
133 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
134 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200135
Jakub Josef79ecec32017-02-17 14:36:28 +0100136 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200137 if (salt.testTarget(master, 'I@haproxy:proxy')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400138 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
139 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
140 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
141 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200142
Jakub Josef79ecec32017-02-17 14:36:28 +0100143 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200144 if (salt.testTarget(master, 'I@memcached:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400145 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
146 }
147
148 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200149 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400150 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
vrovachev076e5c92017-11-13 18:56:17 +0400151 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
vrovachev1c4770b2017-07-05 13:25:21 +0400152 }
153}
154
155def installOpenstackInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200156 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400157
158 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200159 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100160}
161
162
Ales Komarekef2bab62017-04-26 11:48:28 +0200163def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100164 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200165
166 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300167 if (salt.testTarget(master, 'I@horizon:server')) {
168 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
169 }
170 if (salt.testTarget(master, 'I@nginx:server')) {
Richard Felkl34e1b992017-11-02 23:15:06 +0100171 salt.enforceState(master, 'I@nginx:server', 'salt.minion', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300172 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
173 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200174
Jakub Josef79ecec32017-02-17 14:36:28 +0100175 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300176 if (salt.testTarget(master, 'I@keystone:server')) {
177 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
178 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
179 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
180 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100181
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300182 // keystone:client must be called locally
183 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
184 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
185 sleep(30)
186 }
187 if (salt.testTarget(master, 'I@keystone:client')) {
Vasyl Saienkoff6f0f02017-07-19 15:54:16 +0300188 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300189 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
190 }
191 if (salt.testTarget(master, 'I@keystone:server')) {
192 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
193 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100194
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300195 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300196 if (salt.testTarget(master, 'I@glance:server')) {
197 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
198 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
199 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
200 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200201
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300202 // Check glance service
203 if (salt.testTarget(master, 'I@glance:server')){
204 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300205 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200206
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400207 // Create glance resources
208 if (salt.testTarget(master, 'I@glance:client')) {
209 salt.enforceState(master, 'I@glance:client', 'glance.client', true)
210 }
211
Jakub Josef79ecec32017-02-17 14:36:28 +0100212 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300213 if (salt.testTarget(master, 'I@nova:controller')) {
214 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
215 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
216 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
217 if (salt.testTarget(master, 'I@keystone:server')) {
218 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
219 }
220 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200221
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400222 // Create nova resources
223 if (salt.testTarget(master, 'I@nova:client')) {
224 salt.enforceState(master, 'I@nova:client', 'nova.client', true)
225 }
226
Jakub Josef79ecec32017-02-17 14:36:28 +0100227 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300228 if (salt.testTarget(master, 'I@cinder:controller')) {
229 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
230 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
231 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
232 if (salt.testTarget(master, 'I@keystone:server')) {
233 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
234 }
235 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200236
Jakub Josef79ecec32017-02-17 14:36:28 +0100237 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300238 if (salt.testTarget(master, 'I@neutron:server')) {
239 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200240
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300241 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
242 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
243 if (salt.testTarget(master, 'I@keystone:server')) {
244 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
245 }
246 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200247
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400248 // Create neutron resources
249 if (salt.testTarget(master, 'I@neutron:client')) {
250 salt.enforceState(master, 'I@neutron:client', 'neutron.client', true)
251 }
252
Jakub Josef79ecec32017-02-17 14:36:28 +0100253 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300254 if (salt.testTarget(master, 'I@heat:server')) {
255 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
256 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
257 salt.enforceState(master, 'I@heat:server', 'heat', true)
258 if (salt.testTarget(master, 'I@keystone:server')) {
259 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
260 }
261 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200262
263 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300264 if (salt.testTarget(master, 'I@nova:controller')) {
265 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
266 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300267
268 // Install ironic service
269 if (salt.testTarget(master, 'I@ironic:api')) {
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300270 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api', true)
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300271 salt.enforceState(master, 'I@ironic:api', 'ironic.api', true)
272 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300273
274 // Install designate service
275 if (salt.testTarget(master, 'I@designate:server:enabled')) {
276 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
277 salt.enforceState(master, 'I@bind:server', 'bind.server', true)
278 }
279 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
280 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server', true)
281 }
282 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server', true)
283 salt.enforceState(master, 'I@designate:server', 'designate.server', true)
284 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400285
286 // Install octavia api service
287 if (salt.testTarget(master, 'I@octavia:api')) {
288 salt.enforceState(master, 'I@octavia:api', 'octavia', true)
289 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200290
291 // Install barbican server service
292 if (salt.testTarget(master, 'I@barbican:server')) {
Petr Jediný1c717032017-11-03 13:37:34 +0100293 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server', true)
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200294 salt.enforceState(master, 'I@barbican:server', 'barbican.server', true)
295 }
296 // Install barbican client
297 if (salt.testTarget(master, 'I@barbican:client')) {
298 salt.enforceState(master, 'I@barbican:client', 'barbican.client', true)
299 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100300}
301
302
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300303def installIronicConductor(master){
304 def salt = new com.mirantis.mk.Salt()
305
306 if (salt.testTarget(master, 'I@ironic:conductor')) {
307 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor', true)
308 salt.enforceState(master, 'I@ironic:conductor', 'apache', true)
309 }
310 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
311 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa', true)
312 }
313
314 if (salt.testTarget(master, 'I@nova:compute')) {
315 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
316 }
317
318 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
319 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator', true)
320 }
321 if (salt.testTarget(master, 'I@ironic:client')) {
322 salt.enforceState(master, 'I@ironic:client', 'ironic.client', true)
323 }
324}
325
326
327
Ales Komarekef2bab62017-04-26 11:48:28 +0200328def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100329 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200330
331 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400332
333 // install octavia manager services
334 if (salt.testTarget(master, 'I@octavia:manager')) {
335 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'], null, true)
Anastasia Kuznetsova38aee7d2017-09-12 14:28:17 +0400336 salt.enforceState(master, 'I@octavia:manager', 'octavia', true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400337 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca', true)
338 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert', true)
339 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200340}
341
342
343def installOpenstackCompute(master) {
344 def salt = new com.mirantis.mk.Salt()
345
346 // Configure compute nodes
347 retry(2) {
Marek Celoude305ec72017-05-16 11:27:53 +0200348 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200349 }
350}
351
352
353def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200354 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200355 def salt = new com.mirantis.mk.Salt()
356
357
Jakub Josef79ecec32017-02-17 14:36:28 +0100358 // Install opencontrail database services
359 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200360 try {
361 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
362 } catch (Exception e) {
363 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
364 }
365
366 try {
367 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
368 } catch (Exception e) {
369 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
370 }
371
Jakub Josef79ecec32017-02-17 14:36:28 +0100372 // Install opencontrail control services
373 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200374 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
375 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
376 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100377
Jakub Josef79ecec32017-02-17 14:36:28 +0100378 // Test opencontrail
Ales Komarekef2bab62017-04-26 11:48:28 +0200379 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100380}
381
382
Ales Komarekef2bab62017-04-26 11:48:28 +0200383def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200384 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400385 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100386 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200387 // Provision opencontrail control services
388 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100389 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100390
vrovachev4ff77302017-08-09 20:39:57 +0400391 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
392 try {
393 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true)
394 } catch (Exception e) {
395 common.warningMsg('Exception in state opencontrail on I@opencontrail:compute')
396 }
397
Ales Komarekef2bab62017-04-26 11:48:28 +0200398 salt.runSaltProcessStep(master, 'I@nova:compute', 'cmd.run', ['exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "'], null, true)
vrovachev4ff77302017-08-09 20:39:57 +0400399
400 if (salt.testTarget(master, 'I@opencontrail:compute')) {
401 sleep(300)
402 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
403 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true)
404 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100405}
406
407
Ales Komarekef2bab62017-04-26 11:48:28 +0200408def installKubernetesInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200409 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400410 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200411 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100412}
413
414
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200415def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100416 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200417
Jakub Josef79ecec32017-02-17 14:36:28 +0100418 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200419 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
420 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100421
Marek Celoud029391c2017-11-14 10:06:18 +0100422 if (salt.testTarget(master, 'I@etcd:server:setup')) {
423 // Setup etcd server
424 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
425 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100426
427 // Run k8s without master.setup
428 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
429
430 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200431 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100432
433 // Restart kubelet
434 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
435}
436
437
Ales Komarekef2bab62017-04-26 11:48:28 +0200438def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200439 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200440
441 // Refresh minion's pillar data
442 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
443 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
444
445 // Bootstrap all nodes
446 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
447 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
448 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
449
450 // Create and distribute SSL certificates for services using salt state
451 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
452
453 // Install docker
454 salt.enforceState(master, 'I@docker:host', 'docker.host')
455
456 // Install Kubernetes and Calico
457 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
458
Yuriy Taradayab564d72017-10-11 15:14:35 +0400459 // Install Tiller and all configured releases
460 if (salt.testTarget(master, 'I@helm:client')) {
461 salt.enforceState(master, 'I@helm:client', 'helm')
462 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200463}
464
465
Martin Polreich8663a342017-06-30 17:33:08 +0200466def installDockerSwarm(master) {
467 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100468
vrovachev1c4770b2017-07-05 13:25:21 +0400469 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200470 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
471 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
472 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains', true)
473 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update', [], null, true)
474 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules', [], null, true)
475 sleep(5)
Martin Polreich377c37a2017-08-08 15:42:51 +0200476 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200477 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm', true)
478 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200479}
480
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200481
482def installCicd(master) {
483 def salt = new com.mirantis.mk.Salt()
484
485 //Install and Configure Docker
Richard Felkl9d2cd922017-11-03 11:49:32 +0100486 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.refresh_pillar', [], null, true)
487 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.sync_all', [], null, true)
488
Richard Felkl6de16762017-11-20 11:42:28 +0100489 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
490 salt.enforceState(master, 'I@docker:swarm:role:master and I@jenkins:client', 'docker.client', true, true, null, false, -1, 2)
Jiri Broulike57a0242017-10-06 13:38:47 +0200491 sleep(500)
Richard Felkl6de16762017-11-20 11:42:28 +0100492 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
493 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
Richard Felklb6fdec92017-09-26 10:52:36 +0200494
495 if (salt.testTarget(master, 'I@python:environment')) {
496 salt.enforceState(master, 'I@python:environment', 'python', true)
497 }
Richard Felkl6de16762017-11-20 11:42:28 +0100498 salt.enforceState(master, 'I@gerrit:client', 'gerrit', true, true, null, false, -1, 2)
499 salt.enforceState(master, 'I@jenkins:client', 'jenkins', true, true, null, false, -1, 2)
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200500}
501
502
Martin Polreich8663a342017-06-30 17:33:08 +0200503def installStacklight(master) {
504 def common = new com.mirantis.mk.Common()
505 def salt = new com.mirantis.mk.Salt()
506
Simon Pasquieref4122c2017-08-25 15:52:07 +0200507 // Install core services for K8S environments:
508 // HAProxy, Nginx and lusterFS clients
509 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200510 if (common.checkContains('STACK_INSTALL', 'k8s')) {
511 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
512 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200513
514 if (salt.testTarget(master, 'I@nginx:server')) {
515 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
516 }
517
518 if (salt.testTarget(master, 'I@glusterfs:client')) {
519 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
520 }
Martin Polreich792f2662017-07-11 13:36:32 +0200521 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200522
523 // Launch containers
524 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client', true)
525 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps', [], null, true)
526
Martin Polreich8663a342017-06-30 17:33:08 +0200527 //Install Telegraf
Martin Polreichd894e3e2017-07-04 15:35:02 +0200528 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200529
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400530 // Install Prometheus exporters
531 if (salt.testTarget(master, 'I@prometheus:exporters')) {
532 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus', true)
533 }
534
Martin Polreich8663a342017-06-30 17:33:08 +0200535 //Install Elasticsearch and Kibana
Martin Polreichbf7f6162017-07-06 14:43:21 +0200536 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200537 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200538 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200539 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200540 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200541 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200542 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200543 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
544
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200545 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
546
Martin Polreich470925a2017-07-06 17:12:59 +0200547 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200548 if (common.checkContains('STACK_INSTALL', 'k8s')) {
549 withEnv(['ASK_ON_ERROR=false']){
550 retry(2) {
551 salt.enforceState(master, 'I@galera:master', 'galera', true)
552 }
Martin Polreich470925a2017-07-06 17:12:59 +0200553 }
Martin Polreich792f2662017-07-11 13:36:32 +0200554 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Martin Polreich406f6462017-07-11 11:33:42 +0000555
Martin Polreich792f2662017-07-11 13:36:32 +0200556 // Check galera status
557 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
558 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
559 }
Martin Polreich470925a2017-07-06 17:12:59 +0200560
Martin Polreich8663a342017-06-30 17:33:08 +0200561 //Collect Grains
562 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains', true)
563 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules', [], null, true)
564 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update', [], null, true)
565 sleep(5)
566
567 //Configure services in Docker Swarm
Martin Polreich8017f452017-08-21 16:01:42 +0200568 if (common.checkContains('STACK_INSTALL', 'k8s')) {
569 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false)
570 }
571 else {
572 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false)
573 }
Martin Polreich8663a342017-06-30 17:33:08 +0200574
575 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200576 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200577 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200578
Martin Polreich8663a342017-06-30 17:33:08 +0200579 def stacklight_vip
580 if(!pillar['return'].isEmpty()) {
581 stacklight_vip = pillar['return'][0].values()[0]
582 } else {
583 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
584 }
vrovachev1c4770b2017-07-05 13:25:21 +0400585
Martin Polreich305e2222017-07-06 11:33:00 +0200586 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200587 sleep(120)
Martin Polreich8663a342017-06-30 17:33:08 +0200588 salt.enforceState(master, 'I@grafana:client', 'grafana.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200589}
590
591def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200592 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200593
594 // infra install
595 // Install the StackLight backends
596 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
597 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
598
599 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
600 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
601
602 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
603 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
604
605 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
606 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
607
Kalynovskyi3e370112017-06-26 12:48:23 +0300608 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
609 def alarming_service = alarming_service_pillar['return'][0].values()[0]
610
611 switch (alarming_service) {
612 case 'sensu':
613 // Update Sensu
614 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true)
615 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true)
616 salt.enforceState(master, 'I@redis:server', 'redis', true)
617 salt.enforceState(master, 'I@sensu:server', 'sensu', true)
618 default:
619 // Update Nagios
620 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
621 // Stop the Nagios service because the package starts it by default and it will
622 // started later only on the node holding the VIP address
623 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
624 }
625
Ales Komarekef2bab62017-04-26 11:48:28 +0200626 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
Marek Celoudebc623b2017-06-02 17:12:31 +0200627 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200628
629 sleep(10)
630}
631
Martin Polreich8663a342017-06-30 17:33:08 +0200632def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200633 def salt = new com.mirantis.mk.Salt()
634 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200635
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200636 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200637 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200638 salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200639 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
640
641 // Install collectd, heka and sensu services on the nodes, this will also
642 // generate the metadata that goes into the grains and eventually into Salt Mine
643 salt.enforceState(master, '*', 'collectd', true)
644 salt.enforceState(master, '*', 'salt.minion', true)
645 salt.enforceState(master, '*', 'heka', true)
646
647 // Gather the Grafana metadata as grains
648 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
649
650 // Update Salt Mine
651 salt.enforceState(master, '*', 'salt.minion.grains', true)
652 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
653 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
654
655 sleep(5)
656
657 // Update Heka
658 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
659
660 // Update collectd
661 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
662
Kalynovskyi3e370112017-06-26 12:48:23 +0300663 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
664 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200665
Kalynovskyi3e370112017-06-26 12:48:23 +0300666 switch (alarming_service) {
667 case 'sensu':
668 // Update Sensu
669 // TODO for stacklight team, should be fixed in model
670 salt.enforceState(master, 'I@sensu:client', 'sensu', true)
671 default:
672 break
673 // Default is nagios, and was enforced in installStacklightControl()
674 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200675
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200676 salt.runSaltProcessStep(master, 'I@grafana:client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200677 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
678
Marek Celoudd200cad2017-06-07 10:34:46 +0200679 // Finalize the configuration of Grafana (add the dashboards...)
Alexander Noskov8448fc52017-06-21 14:03:45 +0200680 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
681 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true)
682 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true)
Marek Celoudd200cad2017-06-07 10:34:46 +0200683 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
684
Ales Komarekef2bab62017-04-26 11:48:28 +0200685 // Get the StackLight monitoring VIP addres
686 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
687 //vip=${vip:=172.16.10.253}
688 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200689 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200690 def stacklight_vip = pillar['return'][0].values()[0]
691
692 if (stacklight_vip) {
693 // (re)Start manually the services that are bound to the monitoring VIP
694 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
695 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
696 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
697 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
698 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
699 } else {
700 throw new Exception("Missing stacklight_vip")
701 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100702}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200703
704
705//
706// Ceph
707//
708
Tomáš Kukráled27a472017-08-29 10:26:25 +0200709def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200710 def salt = new com.mirantis.mk.Salt()
711
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200712 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains', true)
713
Jiri Broulike57a0242017-10-06 13:38:47 +0200714 // generate keyrings
715 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
716 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200717 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200718 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update', [], null, true)
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200719 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200720 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200721 // install Ceph Mons
Tomáš Kukrál9b4fb512017-08-14 11:01:49 +0200722 salt.enforceState(master, target, 'ceph.mon', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200723 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200724 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200725 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200726}
727
Tomáš Kukráled27a472017-08-29 10:26:25 +0200728def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200729 def salt = new com.mirantis.mk.Salt()
730
731 // install Ceph OSDs
732 salt.enforceState(master, target, 'ceph.osd', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200733 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200734 salt.enforceState(master, target, 'ceph.osd.custom', true)
Jiri Broulik2911deb2017-10-12 20:26:43 +0200735 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
736 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update', [], null, true)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200737
Jiri Broulike57a0242017-10-06 13:38:47 +0200738 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200739 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200740 sleep(5)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200741 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup', true)
742 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200743}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200744
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200745def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200746 def salt = new com.mirantis.mk.Salt()
747
748 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200749 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200750 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains', [], null, true)
Tomáš Kukrál1fe90452017-08-28 18:27:26 +0200751 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw', true)
Jiri Broulik831a74e2017-10-18 08:27:11 +0200752 // setup Keystone service and endpoints for swift or / and S3
753 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200754 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200755}
Jiri Broulike57a0242017-10-06 13:38:47 +0200756
757def connectCeph(master) {
758 def salt = new com.mirantis.mk.Salt()
759
760 // connect Ceph to the env
761 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
762 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'], true)
763 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
764 }
765 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
766 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'], true)
767 }
768 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
769 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'], true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200770 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200771 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'], true)
772 }
773}