blob: 5809e759188acc81f07936b3c0e931a520a791bb [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
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020020 // NOTE(vsaienko) Apply reclass first, it may update cluster model
21 // apply linux and salt.master salt.minion states afterwards to make sure
22 // correct cluster model is used.
23 salt.enforceState(master, 'I@salt:master', ['reclass'], true)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020024
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020025 salt.enforceState(master, 'I@salt:master', ['linux.system'], true)
26 salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020027 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
28 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
29
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030030 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020031 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true)
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020032 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
33 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020034
Jakub Josef200550f2017-05-16 17:39:55 +020035 salt.enforceState(master, '*', ['linux.system'], true)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030036 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'], true)
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020037 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020038 sleep(5)
39 salt.enforceState(master, '*', ['linux.network.host'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010040}
41
Jiri Broulik976bf6c2017-10-20 14:43:25 +020042def installFoundationInfraOnTarget(master, target) {
43 def salt = new com.mirantis.mk.Salt()
44
45 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
46
47 salt.runSaltProcessStep(master, target, 'saltutil.refresh_pillar', [], null, true)
48 salt.runSaltProcessStep(master, target, 'saltutil.sync_all', [], null, true)
49
50 salt.enforceState(master, target, ['linux.system'], true)
51 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
52 salt.enforceState(master, target, ['salt.minion'], true)
53
54 salt.enforceState(master, target, ['linux', 'openssh', 'ntp'], true)
55 sleep(5)
56 salt.enforceState(master, target, ['linux.network.host'], true)
57}
58
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010059def installInfraKvm(master) {
60 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010061
Ales Komarekef2bab62017-04-26 11:48:28 +020062 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
63 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
64
Richard Felkl286f25f2017-07-26 14:23:55 +020065 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030066 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010067 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
68 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010069
Ales Komarekef2bab62017-04-26 11:48:28 +020070 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010071
Marek Celoudc9b3cc82017-05-22 12:50:53 +000072 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true)
73 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010074}
Jakub Josef79ecec32017-02-17 14:36:28 +010075
vrovachev1c4770b2017-07-05 13:25:21 +040076def installInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010077 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020078
Jakub Josef79ecec32017-02-17 14:36:28 +010079 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020080 if (salt.testTarget(master, 'I@glusterfs:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +040081 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010082
vrovachev1c4770b2017-07-05 13:25:21 +040083 withEnv(['ASK_ON_ERROR=false']){
84 retry(5) {
85 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
86 }
Alexander Noskov93acac42017-06-20 17:55:55 +020087 }
vrovachev1c4770b2017-07-05 13:25:21 +040088
89 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
90 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Alexander Noskov93acac42017-06-20 17:55:55 +020091 }
Ales Komarekef2bab62017-04-26 11:48:28 +020092
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030093 // Ensure glusterfs clusters is ready
94 if (salt.testTarget(master, 'I@glusterfs:client')) {
95 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
96 }
97
Jakub Josef79ecec32017-02-17 14:36:28 +010098 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +020099 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400100 withEnv(['ASK_ON_ERROR=false']){
101 retry(2) {
102 salt.enforceState(master, 'I@galera:master', 'galera', true)
103 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200104 }
vrovachev1c4770b2017-07-05 13:25:21 +0400105 salt.enforceState(master, 'I@galera:slave', 'galera', true)
106
107 // Check galera status
108 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
109 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300110 // If galera is not enabled check if we need to install mysql:server
111 } else if (salt.testTarget(master, 'I@mysql:server')){
112 salt.enforceState(master, 'I@mysql:server', 'mysql.server', true)
113 if (salt.testTarget(master, 'I@mysql:client')){
114 salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
115 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200116 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200117
vrovachev1c4770b2017-07-05 13:25:21 +0400118 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200119 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400120 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200121 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400122 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200123
vrovachev1c4770b2017-07-05 13:25:21 +0400124 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200125 if (salt.testTarget(master, 'I@keepalived:cluster')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400126 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
127 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
128 }
129
130 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200131 if (salt.testTarget(master, 'I@rabbitmq:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400132 withEnv(['ASK_ON_ERROR=false']){
133 retry(2) {
134 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
135 }
136 }
137
138 // Check the rabbitmq status
139 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
140 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200141
Jakub Josef79ecec32017-02-17 14:36:28 +0100142 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200143 if (salt.testTarget(master, 'I@haproxy:proxy')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400144 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
145 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
146 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
147 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200148
Jakub Josef79ecec32017-02-17 14:36:28 +0100149 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200150 if (salt.testTarget(master, 'I@memcached:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400151 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
152 }
153
154 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200155 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400156 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
vrovachev076e5c92017-11-13 18:56:17 +0400157 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
vrovachev1c4770b2017-07-05 13:25:21 +0400158 }
159}
160
161def installOpenstackInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200162 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400163
164 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200165 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100166}
167
168
Ales Komarekef2bab62017-04-26 11:48:28 +0200169def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100170 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200171
172 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300173 if (salt.testTarget(master, 'I@horizon:server')) {
174 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
175 }
176 if (salt.testTarget(master, 'I@nginx:server')) {
Richard Felkl34e1b992017-11-02 23:15:06 +0100177 salt.enforceState(master, 'I@nginx:server', 'salt.minion', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300178 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
179 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200180
Jakub Josef79ecec32017-02-17 14:36:28 +0100181 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300182 if (salt.testTarget(master, 'I@keystone:server')) {
183 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
184 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
185 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
186 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100187
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300188 // keystone:client must be called locally
189 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
190 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
191 sleep(30)
192 }
193 if (salt.testTarget(master, 'I@keystone:client')) {
Vasyl Saienkoff6f0f02017-07-19 15:54:16 +0300194 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300195 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
196 }
197 if (salt.testTarget(master, 'I@keystone:server')) {
198 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
199 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100200
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300201 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300202 if (salt.testTarget(master, 'I@glance:server')) {
203 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
204 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
205 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
206 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200207
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300208 // Check glance service
209 if (salt.testTarget(master, 'I@glance:server')){
210 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300211 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200212
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400213 // Create glance resources
214 if (salt.testTarget(master, 'I@glance:client')) {
215 salt.enforceState(master, 'I@glance:client', 'glance.client', true)
216 }
217
Jakub Josef79ecec32017-02-17 14:36:28 +0100218 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300219 if (salt.testTarget(master, 'I@nova:controller')) {
220 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
221 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
222 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
223 if (salt.testTarget(master, 'I@keystone:server')) {
224 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
225 }
226 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200227
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400228 // Create nova resources
229 if (salt.testTarget(master, 'I@nova:client')) {
230 salt.enforceState(master, 'I@nova:client', 'nova.client', true)
231 }
232
Jakub Josef79ecec32017-02-17 14:36:28 +0100233 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300234 if (salt.testTarget(master, 'I@cinder:controller')) {
235 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
236 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
237 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
238 if (salt.testTarget(master, 'I@keystone:server')) {
239 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
240 }
241 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200242
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300244 if (salt.testTarget(master, 'I@neutron:server')) {
245 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200246
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300247 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
248 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
249 if (salt.testTarget(master, 'I@keystone:server')) {
250 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
251 }
252 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200253
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400254 // Create neutron resources
255 if (salt.testTarget(master, 'I@neutron:client')) {
256 salt.enforceState(master, 'I@neutron:client', 'neutron.client', true)
257 }
258
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300260 if (salt.testTarget(master, 'I@heat:server')) {
261 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
262 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
263 salt.enforceState(master, 'I@heat:server', 'heat', true)
264 if (salt.testTarget(master, 'I@keystone:server')) {
265 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
266 }
267 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200268
269 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300270 if (salt.testTarget(master, 'I@nova:controller')) {
271 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
272 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300273
274 // Install ironic service
275 if (salt.testTarget(master, 'I@ironic:api')) {
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300276 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api', true)
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300277 salt.enforceState(master, 'I@ironic:api', 'ironic.api', true)
278 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300279
280 // Install designate service
281 if (salt.testTarget(master, 'I@designate:server:enabled')) {
282 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
283 salt.enforceState(master, 'I@bind:server', 'bind.server', true)
284 }
285 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
286 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server', true)
287 }
288 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server', true)
289 salt.enforceState(master, 'I@designate:server', 'designate.server', true)
290 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400291
292 // Install octavia api service
293 if (salt.testTarget(master, 'I@octavia:api')) {
294 salt.enforceState(master, 'I@octavia:api', 'octavia', true)
295 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200296
297 // Install barbican server service
298 if (salt.testTarget(master, 'I@barbican:server')) {
Petr Jediný1c717032017-11-03 13:37:34 +0100299 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server', true)
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200300 salt.enforceState(master, 'I@barbican:server', 'barbican.server', true)
301 }
302 // Install barbican client
303 if (salt.testTarget(master, 'I@barbican:client')) {
304 salt.enforceState(master, 'I@barbican:client', 'barbican.client', true)
305 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100306}
307
308
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300309def installIronicConductor(master){
310 def salt = new com.mirantis.mk.Salt()
311
312 if (salt.testTarget(master, 'I@ironic:conductor')) {
313 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor', true)
314 salt.enforceState(master, 'I@ironic:conductor', 'apache', true)
315 }
316 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
317 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa', true)
318 }
319
320 if (salt.testTarget(master, 'I@nova:compute')) {
321 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
322 }
323
324 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
325 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator', true)
326 }
327 if (salt.testTarget(master, 'I@ironic:client')) {
328 salt.enforceState(master, 'I@ironic:client', 'ironic.client', true)
329 }
330}
331
332
333
Ales Komarekef2bab62017-04-26 11:48:28 +0200334def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100335 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200336
337 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400338
339 // install octavia manager services
340 if (salt.testTarget(master, 'I@octavia:manager')) {
341 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'], null, true)
Anastasia Kuznetsova38aee7d2017-09-12 14:28:17 +0400342 salt.enforceState(master, 'I@octavia:manager', 'octavia', true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400343 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca', true)
344 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert', true)
345 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200346}
347
348
349def installOpenstackCompute(master) {
350 def salt = new com.mirantis.mk.Salt()
351
352 // Configure compute nodes
353 retry(2) {
Marek Celoude305ec72017-05-16 11:27:53 +0200354 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200355 }
356}
357
358
359def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200360 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200361 def salt = new com.mirantis.mk.Salt()
362
363
Jakub Josef79ecec32017-02-17 14:36:28 +0100364 // Install opencontrail database services
365 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Jakub Josef0e17ec02017-11-28 13:49:41 +0100366 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
Ales Komarekef2bab62017-04-26 11:48:28 +0200367 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200368 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
Jakub Josef0e17ec02017-11-28 13:49:41 +0100369 }else{
370 try {
371 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
372 } catch (Exception e) {
373 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
374 }
375 try {
376 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
377 } catch (Exception e) {
378 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
379 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200380 }
381
Jakub Josef79ecec32017-02-17 14:36:28 +0100382 // Install opencontrail control services
383 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200384 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
385 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
386 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100387
Marek Celoud443fb642017-11-22 15:07:12 +0100388 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
389 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client', true)
390 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100391}
392
393
Ales Komarekef2bab62017-04-26 11:48:28 +0200394def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200395 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400396 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100397 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200398 // Provision opencontrail control services
399 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100400 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100401
vrovachev4ff77302017-08-09 20:39:57 +0400402 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Jakub Josef0e17ec02017-11-28 13:49:41 +0100403 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
Marek Celoud443fb642017-11-22 15:07:12 +0100404 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Jakub Josef0e17ec02017-11-28 13:49:41 +0100405 }else{
406 try {
407 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
408 } catch (Exception e) {
409 common.warningMsg('Exception in state opencontrail on I@opencontrail:compute')
410 }
vrovachev4ff77302017-08-09 20:39:57 +0400411 }
412
Ales Komarekef2bab62017-04-26 11:48:28 +0200413 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 +0400414
415 if (salt.testTarget(master, 'I@opencontrail:compute')) {
416 sleep(300)
417 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
418 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true)
419 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100420}
421
422
Ales Komarekef2bab62017-04-26 11:48:28 +0200423def installKubernetesInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200424 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400425 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200426 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100427}
428
429
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200430def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100431 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200432
Jakub Josef79ecec32017-02-17 14:36:28 +0100433 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200434 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
435 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100436
Marek Celoud029391c2017-11-14 10:06:18 +0100437 if (salt.testTarget(master, 'I@etcd:server:setup')) {
438 // Setup etcd server
439 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
440 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100441
442 // Run k8s without master.setup
443 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
444
445 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200446 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100447
448 // Restart kubelet
449 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
450}
451
452
Ales Komarekef2bab62017-04-26 11:48:28 +0200453def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200454 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200455
456 // Refresh minion's pillar data
457 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
458 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
459
460 // Bootstrap all nodes
461 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
462 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
463 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
464
465 // Create and distribute SSL certificates for services using salt state
466 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
467
468 // Install docker
469 salt.enforceState(master, 'I@docker:host', 'docker.host')
470
471 // Install Kubernetes and Calico
472 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
473
Yuriy Taradayab564d72017-10-11 15:14:35 +0400474 // Install Tiller and all configured releases
475 if (salt.testTarget(master, 'I@helm:client')) {
476 salt.enforceState(master, 'I@helm:client', 'helm')
477 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200478}
479
480
Martin Polreich8663a342017-06-30 17:33:08 +0200481def installDockerSwarm(master) {
482 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100483
vrovachev1c4770b2017-07-05 13:25:21 +0400484 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200485 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
486 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
487 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains', true)
488 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update', [], null, true)
489 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules', [], null, true)
490 sleep(5)
Martin Polreich377c37a2017-08-08 15:42:51 +0200491 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200492 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm', true)
493 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200494}
495
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200496
497def installCicd(master) {
498 def salt = new com.mirantis.mk.Salt()
499
500 //Install and Configure Docker
Richard Felkl9d2cd922017-11-03 11:49:32 +0100501 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.refresh_pillar', [], null, true)
502 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.sync_all', [], null, true)
503
Richard Felkl6de16762017-11-20 11:42:28 +0100504 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
505 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 +0200506 sleep(500)
Richard Felkl6de16762017-11-20 11:42:28 +0100507 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
508 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
Richard Felklb6fdec92017-09-26 10:52:36 +0200509
510 if (salt.testTarget(master, 'I@python:environment')) {
511 salt.enforceState(master, 'I@python:environment', 'python', true)
512 }
Richard Felkl6e208fc2017-12-08 10:18:44 +0100513 withEnv(['ASK_ON_ERROR=false']){
514 retry(2){
515 try{
516 salt.enforceState(master, 'I@gerrit:client', 'gerrit', true)
517 }catch(e){
518 salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.refresh_pillar', [], null, true)
519 salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.sync_all', [], null, true)
520 throw e //rethrow for retry handler
521 }
522 }
523 retry(2){
524 try{
525 salt.enforceState(master, 'I@jenkins:client', 'jenkins', true)
526 }catch(e){
527 salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.refresh_pillar', [], null, true)
528 salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.sync_all', [], null, true)
529 throw e //rethrow for retry handler
530 }
531 }
532 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200533}
534
535
Martin Polreich8663a342017-06-30 17:33:08 +0200536def installStacklight(master) {
537 def common = new com.mirantis.mk.Common()
538 def salt = new com.mirantis.mk.Salt()
539
Simon Pasquieref4122c2017-08-25 15:52:07 +0200540 // Install core services for K8S environments:
541 // HAProxy, Nginx and lusterFS clients
542 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200543 if (common.checkContains('STACK_INSTALL', 'k8s')) {
544 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
545 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200546
547 if (salt.testTarget(master, 'I@nginx:server')) {
548 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
549 }
550
551 if (salt.testTarget(master, 'I@glusterfs:client')) {
552 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
553 }
Martin Polreich792f2662017-07-11 13:36:32 +0200554 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200555
556 // Launch containers
557 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client', true)
558 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps', [], null, true)
559
Martin Polreich8663a342017-06-30 17:33:08 +0200560 //Install Telegraf
Martin Polreichd894e3e2017-07-04 15:35:02 +0200561 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200562
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400563 // Install Prometheus exporters
564 if (salt.testTarget(master, 'I@prometheus:exporters')) {
565 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus', true)
566 }
567
Martin Polreich8663a342017-06-30 17:33:08 +0200568 //Install Elasticsearch and Kibana
Martin Polreichbf7f6162017-07-06 14:43:21 +0200569 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200570 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200571 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200572 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200573 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200574 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200575 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200576 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
577
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200578 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
579
Martin Polreich470925a2017-07-06 17:12:59 +0200580 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200581 if (common.checkContains('STACK_INSTALL', 'k8s')) {
582 withEnv(['ASK_ON_ERROR=false']){
583 retry(2) {
584 salt.enforceState(master, 'I@galera:master', 'galera', true)
585 }
Martin Polreich470925a2017-07-06 17:12:59 +0200586 }
Martin Polreich792f2662017-07-11 13:36:32 +0200587 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Martin Polreich406f6462017-07-11 11:33:42 +0000588
Martin Polreich792f2662017-07-11 13:36:32 +0200589 // Check galera status
590 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
591 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
592 }
Martin Polreich470925a2017-07-06 17:12:59 +0200593
Martin Polreich8663a342017-06-30 17:33:08 +0200594 //Collect Grains
595 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains', true)
596 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules', [], null, true)
597 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update', [], null, true)
598 sleep(5)
599
600 //Configure services in Docker Swarm
Martin Polreich8017f452017-08-21 16:01:42 +0200601 if (common.checkContains('STACK_INSTALL', 'k8s')) {
602 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false)
603 }
604 else {
605 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false)
606 }
Martin Polreich8663a342017-06-30 17:33:08 +0200607
608 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200609 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200610 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200611
Martin Polreich8663a342017-06-30 17:33:08 +0200612 def stacklight_vip
613 if(!pillar['return'].isEmpty()) {
614 stacklight_vip = pillar['return'][0].values()[0]
615 } else {
616 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
617 }
vrovachev1c4770b2017-07-05 13:25:21 +0400618
Martin Polreich305e2222017-07-06 11:33:00 +0200619 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200620 sleep(120)
Martin Polreich8663a342017-06-30 17:33:08 +0200621 salt.enforceState(master, 'I@grafana:client', 'grafana.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200622}
623
624def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200625 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200626
627 // infra install
628 // Install the StackLight backends
629 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
630 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
631
632 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
633 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
634
635 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
636 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
637
638 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
639 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
640
Kalynovskyi3e370112017-06-26 12:48:23 +0300641 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
642 def alarming_service = alarming_service_pillar['return'][0].values()[0]
643
644 switch (alarming_service) {
645 case 'sensu':
646 // Update Sensu
647 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true)
648 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true)
649 salt.enforceState(master, 'I@redis:server', 'redis', true)
650 salt.enforceState(master, 'I@sensu:server', 'sensu', true)
651 default:
652 // Update Nagios
653 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
654 // Stop the Nagios service because the package starts it by default and it will
655 // started later only on the node holding the VIP address
656 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
657 }
658
Ales Komarekef2bab62017-04-26 11:48:28 +0200659 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
Marek Celoudebc623b2017-06-02 17:12:31 +0200660 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200661
662 sleep(10)
663}
664
Martin Polreich8663a342017-06-30 17:33:08 +0200665def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200666 def salt = new com.mirantis.mk.Salt()
667 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200668
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200669 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200670 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200671 salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200672 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
673
674 // Install collectd, heka and sensu services on the nodes, this will also
675 // generate the metadata that goes into the grains and eventually into Salt Mine
676 salt.enforceState(master, '*', 'collectd', true)
677 salt.enforceState(master, '*', 'salt.minion', true)
678 salt.enforceState(master, '*', 'heka', true)
679
680 // Gather the Grafana metadata as grains
681 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
682
683 // Update Salt Mine
684 salt.enforceState(master, '*', 'salt.minion.grains', true)
685 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
686 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
687
688 sleep(5)
689
690 // Update Heka
691 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
692
693 // Update collectd
694 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
695
Kalynovskyi3e370112017-06-26 12:48:23 +0300696 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
697 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200698
Kalynovskyi3e370112017-06-26 12:48:23 +0300699 switch (alarming_service) {
700 case 'sensu':
701 // Update Sensu
702 // TODO for stacklight team, should be fixed in model
703 salt.enforceState(master, 'I@sensu:client', 'sensu', true)
704 default:
705 break
706 // Default is nagios, and was enforced in installStacklightControl()
707 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200708
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200709 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 +0200710 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
711
Marek Celoudd200cad2017-06-07 10:34:46 +0200712 // Finalize the configuration of Grafana (add the dashboards...)
Alexander Noskov8448fc52017-06-21 14:03:45 +0200713 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
714 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true)
715 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true)
Marek Celoudd200cad2017-06-07 10:34:46 +0200716 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
717
Ales Komarekef2bab62017-04-26 11:48:28 +0200718 // Get the StackLight monitoring VIP addres
719 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
720 //vip=${vip:=172.16.10.253}
721 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200722 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200723 def stacklight_vip = pillar['return'][0].values()[0]
724
725 if (stacklight_vip) {
726 // (re)Start manually the services that are bound to the monitoring VIP
727 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
728 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
729 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
730 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
731 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
732 } else {
733 throw new Exception("Missing stacklight_vip")
734 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100735}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200736
737
738//
739// Ceph
740//
741
Tomáš Kukráled27a472017-08-29 10:26:25 +0200742def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200743 def salt = new com.mirantis.mk.Salt()
744
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200745 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains', true)
746
Jiri Broulike57a0242017-10-06 13:38:47 +0200747 // generate keyrings
748 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
749 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200750 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200751 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 +0200752 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200753 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200754 // install Ceph Mons
Tomáš Kukrál9b4fb512017-08-14 11:01:49 +0200755 salt.enforceState(master, target, 'ceph.mon', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200756 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200757 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200758 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200759}
760
Tomáš Kukráled27a472017-08-29 10:26:25 +0200761def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200762 def salt = new com.mirantis.mk.Salt()
763
764 // install Ceph OSDs
765 salt.enforceState(master, target, 'ceph.osd', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200766 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200767 salt.enforceState(master, target, 'ceph.osd.custom', true)
Jiri Broulik2911deb2017-10-12 20:26:43 +0200768 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
769 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update', [], null, true)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200770
Jiri Broulike57a0242017-10-06 13:38:47 +0200771 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200772 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200773 sleep(5)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200774 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup', true)
775 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200776}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200777
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200778def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200779 def salt = new com.mirantis.mk.Salt()
780
781 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200782 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200783 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains', [], null, true)
Tomáš Kukrál1fe90452017-08-28 18:27:26 +0200784 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw', true)
Alexander Noskov229035f2017-12-06 00:10:20 +0400785 }
786 // setup Keystone service and endpoints for swift or / and S3
787 if (salt.testTarget(master, 'I@keystone:client')) {
Jiri Broulik831a74e2017-10-18 08:27:11 +0200788 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200789 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200790}
Jiri Broulike57a0242017-10-06 13:38:47 +0200791
792def connectCeph(master) {
793 def salt = new com.mirantis.mk.Salt()
794
795 // connect Ceph to the env
796 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
797 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'], true)
798 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
799 }
800 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
801 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'], true)
802 }
803 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
804 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'], true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200805 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200806 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'], true)
807 }
808}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400809
810def installOssInfra(master) {
811 def common = new com.mirantis.mk.Common()
812 def salt = new com.mirantis.mk.Salt()
813
814 if (!common.checkContains('STACK_INSTALL', 'k8s')) or (!common.checkContains('STACK_INSTALL', 'openstack')) {
815 def orchestrate = new com.mirantis.mk.Orchestrate()
816 orchestrate.installInfra(master)
817 }
818
819 if (salt.testTarget(master, 'I@devops_portal:config')) {
820 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config', true)
821 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'], true)
822 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server', true)
823 }
824}
825
826def installOss(master) {
827 def common = new com.mirantis.mk.Common()
828 def salt = new com.mirantis.mk.Salt()
829
830 //Get oss VIP address
831 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
832 common.prettyPrint(pillar)
833
834 def oss_vip
835 if(!pillar['return'].isEmpty()) {
836 oss_vip = pillar['return'][0].values()[0]
837 } else {
838 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
839 }
840
841 // Postgres client - initialize OSS services databases
842 timeout(120){
843 common.infoMsg("Waiting for postgresql database to come up..")
844 salt.cmdRun(master, 'I@postgresql:client', 'while true; do if docker service logs postgresql_postgresql-db | grep "ready to accept"; then break; else sleep 5; fi; done')
845 }
846 // XXX: first run usually fails on some inserts, but we need to create databases at first
847 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
848
849 // Setup postgres database with integration between
850 // Pushkin notification service and Security Monkey security audit service
851 timeout(10) {
852 common.infoMsg("Waiting for Pushkin to come up..")
853 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
854 }
855 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true)
856
857 // Rundeck
858 timeout(10) {
859 common.infoMsg("Waiting for Rundeck to come up..")
860 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
861 }
862 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client', true)
863
864 // Elasticsearch
865 timeout(10) {
866 common.infoMsg('Waiting for Elasticsearch to come up..')
867 salt.cmdRun(master, 'I@elasticsearch:client', "while true; do curl -sf ${oss_vip}:9200 >/dev/null && break; done")
868 }
869 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
870}