blob: 2afbd4987bd1b3e0f6cde5bc227e8638097c7979 [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
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010017def installFoundationInfra(master, staticMgmtNet=false) {
Jakub Josef79ecec32017-02-17 14:36:28 +010018 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)
Andrey Shestakov13b83712018-01-23 11:53:05 +020033 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_grains', [], null, true)
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020034 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020035
Jakub Josef200550f2017-05-16 17:39:55 +020036 salt.enforceState(master, '*', ['linux.system'], true)
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010037 if (staticMgmtNet) {
38 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
39 }
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030040 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'], true)
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020041 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020042 sleep(5)
43 salt.enforceState(master, '*', ['linux.network.host'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010044}
45
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010046def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020047 def salt = new com.mirantis.mk.Salt()
48
49 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
50
51 salt.runSaltProcessStep(master, target, 'saltutil.refresh_pillar', [], null, true)
52 salt.runSaltProcessStep(master, target, 'saltutil.sync_all', [], null, true)
53
54 salt.enforceState(master, target, ['linux.system'], true)
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010055 if (staticMgmtNet) {
56 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
57 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020058 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
59 salt.enforceState(master, target, ['salt.minion'], true)
60
61 salt.enforceState(master, target, ['linux', 'openssh', 'ntp'], true)
62 sleep(5)
63 salt.enforceState(master, target, ['linux.network.host'], true)
64}
65
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010066def installInfraKvm(master) {
67 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010068
Ales Komarekef2bab62017-04-26 11:48:28 +020069 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
70 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
71
Richard Felkl286f25f2017-07-26 14:23:55 +020072 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030073 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010074 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
75 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010076
Ales Komarekef2bab62017-04-26 11:48:28 +020077 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010078
Marek Celoudc9b3cc82017-05-22 12:50:53 +000079 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true)
80 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010081}
Jakub Josef79ecec32017-02-17 14:36:28 +010082
vrovachev1c4770b2017-07-05 13:25:21 +040083def installInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010084 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020085
Jakub Josef79ecec32017-02-17 14:36:28 +010086 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020087 if (salt.testTarget(master, 'I@glusterfs:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +040088 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010089
vrovachev1c4770b2017-07-05 13:25:21 +040090 withEnv(['ASK_ON_ERROR=false']){
91 retry(5) {
92 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
93 }
Alexander Noskov93acac42017-06-20 17:55:55 +020094 }
vrovachev1c4770b2017-07-05 13:25:21 +040095
96 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
97 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Alexander Noskov93acac42017-06-20 17:55:55 +020098 }
Ales Komarekef2bab62017-04-26 11:48:28 +020099
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300100 // Ensure glusterfs clusters is ready
101 if (salt.testTarget(master, 'I@glusterfs:client')) {
102 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
103 }
104
Jakub Josef79ecec32017-02-17 14:36:28 +0100105 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200106 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400107 withEnv(['ASK_ON_ERROR=false']){
108 retry(2) {
109 salt.enforceState(master, 'I@galera:master', 'galera', true)
110 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200111 }
vrovachev1c4770b2017-07-05 13:25:21 +0400112 salt.enforceState(master, 'I@galera:slave', 'galera', true)
113
114 // Check galera status
115 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
116 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300117 // If galera is not enabled check if we need to install mysql:server
118 } else if (salt.testTarget(master, 'I@mysql:server')){
119 salt.enforceState(master, 'I@mysql:server', 'mysql.server', true)
120 if (salt.testTarget(master, 'I@mysql:client')){
121 salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
122 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200123 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200124
vrovachev1c4770b2017-07-05 13:25:21 +0400125 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200126 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400127 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200128 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400129 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200130
vrovachev1c4770b2017-07-05 13:25:21 +0400131 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200132 if (salt.testTarget(master, 'I@keepalived:cluster')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400133 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
134 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
135 }
136
137 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200138 if (salt.testTarget(master, 'I@rabbitmq:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400139 withEnv(['ASK_ON_ERROR=false']){
140 retry(2) {
141 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
142 }
143 }
144
145 // Check the rabbitmq status
146 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
147 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200148
Jakub Josef79ecec32017-02-17 14:36:28 +0100149 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200150 if (salt.testTarget(master, 'I@haproxy:proxy')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400151 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
152 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
153 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
154 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200155
Jakub Josef79ecec32017-02-17 14:36:28 +0100156 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200157 if (salt.testTarget(master, 'I@memcached:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400158 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
159 }
160
161 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200162 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400163 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
vrovachev076e5c92017-11-13 18:56:17 +0400164 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
vrovachev1c4770b2017-07-05 13:25:21 +0400165 }
166}
167
168def installOpenstackInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200169 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400170
171 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200172 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100173}
174
175
Ales Komarekef2bab62017-04-26 11:48:28 +0200176def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100177 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200178
179 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300180 if (salt.testTarget(master, 'I@horizon:server')) {
181 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
182 }
183 if (salt.testTarget(master, 'I@nginx:server')) {
Richard Felkl34e1b992017-11-02 23:15:06 +0100184 salt.enforceState(master, 'I@nginx:server', 'salt.minion', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300185 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
186 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200187
Jakub Josef79ecec32017-02-17 14:36:28 +0100188 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300189 if (salt.testTarget(master, 'I@keystone:server')) {
190 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
191 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
192 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
193 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100194
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300195 // keystone:client must be called locally
196 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
197 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
198 sleep(30)
199 }
200 if (salt.testTarget(master, 'I@keystone:client')) {
Vasyl Saienkoff6f0f02017-07-19 15:54:16 +0300201 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client', true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300202 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
203 }
204 if (salt.testTarget(master, 'I@keystone:server')) {
205 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
206 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100207
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300208 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300209 if (salt.testTarget(master, 'I@glance:server')) {
210 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
211 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
212 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
213 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200214
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300215 // Check glance service
216 if (salt.testTarget(master, 'I@glance:server')){
217 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300218 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200219
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400220 // Create glance resources
221 if (salt.testTarget(master, 'I@glance:client')) {
222 salt.enforceState(master, 'I@glance:client', 'glance.client', true)
223 }
224
Jakub Josef79ecec32017-02-17 14:36:28 +0100225 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300226 if (salt.testTarget(master, 'I@nova:controller')) {
227 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
228 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
229 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
230 if (salt.testTarget(master, 'I@keystone:server')) {
231 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
232 }
233 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200234
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400235 // Create nova resources
236 if (salt.testTarget(master, 'I@nova:client')) {
237 salt.enforceState(master, 'I@nova:client', 'nova.client', true)
238 }
239
Jakub Josef79ecec32017-02-17 14:36:28 +0100240 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300241 if (salt.testTarget(master, 'I@cinder:controller')) {
242 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
243 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
244 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
245 if (salt.testTarget(master, 'I@keystone:server')) {
246 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
247 }
248 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200249
Jakub Josef79ecec32017-02-17 14:36:28 +0100250 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300251 if (salt.testTarget(master, 'I@neutron:server')) {
252 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200253
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300254 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
255 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
256 if (salt.testTarget(master, 'I@keystone:server')) {
257 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
258 }
259 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200260
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400261 // Create neutron resources
262 if (salt.testTarget(master, 'I@neutron:client')) {
263 salt.enforceState(master, 'I@neutron:client', 'neutron.client', true)
264 }
265
Jakub Josef79ecec32017-02-17 14:36:28 +0100266 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300267 if (salt.testTarget(master, 'I@heat:server')) {
268 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
269 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
270 salt.enforceState(master, 'I@heat:server', 'heat', true)
271 if (salt.testTarget(master, 'I@keystone:server')) {
272 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
273 }
274 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200275
276 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300277 if (salt.testTarget(master, 'I@nova:controller')) {
278 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
279 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300280
281 // Install ironic service
282 if (salt.testTarget(master, 'I@ironic:api')) {
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300283 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api', true)
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300284 salt.enforceState(master, 'I@ironic:api', 'ironic.api', true)
285 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300286
287 // Install designate service
288 if (salt.testTarget(master, 'I@designate:server:enabled')) {
289 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
290 salt.enforceState(master, 'I@bind:server', 'bind.server', true)
291 }
292 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
293 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server', true)
294 }
295 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server', true)
296 salt.enforceState(master, 'I@designate:server', 'designate.server', true)
297 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400298
299 // Install octavia api service
300 if (salt.testTarget(master, 'I@octavia:api')) {
301 salt.enforceState(master, 'I@octavia:api', 'octavia', true)
302 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200303
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200304 // Install DogTag server service
305 if (salt.testTarget(master, 'I@dogtag:server')) {
306 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server', true)
307 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server', true)
308 }
309
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200310 // Install barbican server service
311 if (salt.testTarget(master, 'I@barbican:server')) {
Petr Jediný1c717032017-11-03 13:37:34 +0100312 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server', true)
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200313 salt.enforceState(master, 'I@barbican:server', 'barbican.server', true)
314 }
315 // Install barbican client
316 if (salt.testTarget(master, 'I@barbican:client')) {
317 salt.enforceState(master, 'I@barbican:client', 'barbican.client', true)
318 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100319
320 // Install ceilometer server
321 if (salt.testTarget(master, 'I@ceilometer:server')) {
322 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer', true)
323 }
324
325 // Install aodh server
326 if (salt.testTarget(master, 'I@aodh:server')) {
327 salt.enforceState(master, 'I@aodh:server', 'aodh', true)
328 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100329}
330
331
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300332def installIronicConductor(master){
333 def salt = new com.mirantis.mk.Salt()
334
335 if (salt.testTarget(master, 'I@ironic:conductor')) {
336 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor', true)
337 salt.enforceState(master, 'I@ironic:conductor', 'apache', true)
338 }
339 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
340 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa', true)
341 }
342
343 if (salt.testTarget(master, 'I@nova:compute')) {
344 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
345 }
346
347 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
348 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator', true)
349 }
350 if (salt.testTarget(master, 'I@ironic:client')) {
351 salt.enforceState(master, 'I@ironic:client', 'ironic.client', true)
352 }
353}
354
355
356
Ales Komarekef2bab62017-04-26 11:48:28 +0200357def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100358 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200359
360 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400361
362 // install octavia manager services
363 if (salt.testTarget(master, 'I@octavia:manager')) {
364 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'], null, true)
Anastasia Kuznetsova38aee7d2017-09-12 14:28:17 +0400365 salt.enforceState(master, 'I@octavia:manager', 'octavia', true)
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400366 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca', true)
367 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert', true)
368 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200369}
370
371
372def installOpenstackCompute(master) {
373 def salt = new com.mirantis.mk.Salt()
374
375 // Configure compute nodes
376 retry(2) {
Marek Celoude305ec72017-05-16 11:27:53 +0200377 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200378 }
379}
380
381
382def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200383 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200384 def salt = new com.mirantis.mk.Salt()
385
386
Jakub Josef79ecec32017-02-17 14:36:28 +0100387 // Install opencontrail database services
388 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Jakub Josef0e17ec02017-11-28 13:49:41 +0100389 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
Ales Komarekef2bab62017-04-26 11:48:28 +0200390 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200391 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
Jakub Josef0e17ec02017-11-28 13:49:41 +0100392 }else{
393 try {
394 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
395 } catch (Exception e) {
396 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
397 }
398 try {
399 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
400 } catch (Exception e) {
401 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
402 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200403 }
404
Jakub Josef79ecec32017-02-17 14:36:28 +0100405 // Install opencontrail control services
406 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200407 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
408 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
409 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100410
Marek Celoud443fb642017-11-22 15:07:12 +0100411 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
412 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client', true)
413 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100414}
415
416
Ales Komarekef2bab62017-04-26 11:48:28 +0200417def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200418 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400419 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100420 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200421 // Provision opencontrail control services
422 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100423 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100424
vrovachev4ff77302017-08-09 20:39:57 +0400425 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Jakub Josef0e17ec02017-11-28 13:49:41 +0100426 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
Marek Celoud443fb642017-11-22 15:07:12 +0100427 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Jakub Josef0e17ec02017-11-28 13:49:41 +0100428 }else{
429 try {
430 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
431 } catch (Exception e) {
432 common.warningMsg('Exception in state opencontrail on I@opencontrail:compute')
433 }
vrovachev4ff77302017-08-09 20:39:57 +0400434 }
435
Ales Komarekef2bab62017-04-26 11:48:28 +0200436 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 +0400437
438 if (salt.testTarget(master, 'I@opencontrail:compute')) {
439 sleep(300)
440 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
441 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true)
442 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100443}
444
445
Ales Komarekef2bab62017-04-26 11:48:28 +0200446def installKubernetesInfra(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200447 def orchestrate = new com.mirantis.mk.Orchestrate()
vrovachev1c4770b2017-07-05 13:25:21 +0400448 // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200449 orchestrate.installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100450}
451
452
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200453def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100454 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200455
Jakub Josef79ecec32017-02-17 14:36:28 +0100456 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200457 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
458 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100459
Marek Celoud029391c2017-11-14 10:06:18 +0100460 if (salt.testTarget(master, 'I@etcd:server:setup')) {
461 // Setup etcd server
462 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
463 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100464
465 // Run k8s without master.setup
466 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
467
468 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200469 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100470
471 // Restart kubelet
472 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
473}
474
475
Ales Komarekef2bab62017-04-26 11:48:28 +0200476def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200477 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200478
479 // Refresh minion's pillar data
480 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
481 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
482
483 // Bootstrap all nodes
484 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
485 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
486 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
487
488 // Create and distribute SSL certificates for services using salt state
489 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
490
491 // Install docker
492 salt.enforceState(master, 'I@docker:host', 'docker.host')
493
494 // Install Kubernetes and Calico
495 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
496
Yuriy Taradayab564d72017-10-11 15:14:35 +0400497 // Install Tiller and all configured releases
498 if (salt.testTarget(master, 'I@helm:client')) {
499 salt.enforceState(master, 'I@helm:client', 'helm')
500 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200501}
502
503
Martin Polreich8663a342017-06-30 17:33:08 +0200504def installDockerSwarm(master) {
505 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100506
vrovachev1c4770b2017-07-05 13:25:21 +0400507 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200508 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
509 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
510 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains', true)
511 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update', [], null, true)
512 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules', [], null, true)
513 sleep(5)
Martin Polreich377c37a2017-08-08 15:42:51 +0200514 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200515 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm', true)
516 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200517}
518
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200519
520def installCicd(master) {
521 def salt = new com.mirantis.mk.Salt()
522
523 //Install and Configure Docker
Richard Felkl9d2cd922017-11-03 11:49:32 +0100524 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.refresh_pillar', [], null, true)
525 salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.sync_all', [], null, true)
526
Richard Felklc1aba9b2018-01-02 09:25:20 +0100527 if (salt.testTarget(master, 'I@aptly:publisher')) {
528 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
529 }
530
Richard Felkl6de16762017-11-20 11:42:28 +0100531 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 +0200532 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100533
534 if (salt.testTarget(master, 'I@aptly:server')) {
535 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
536 }
537
538 if (salt.testTarget(master, 'I@openldap:client')) {
539 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
540 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200541
542 if (salt.testTarget(master, 'I@python:environment')) {
543 salt.enforceState(master, 'I@python:environment', 'python', true)
544 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100545
Richard Felkl6e208fc2017-12-08 10:18:44 +0100546 withEnv(['ASK_ON_ERROR=false']){
547 retry(2){
548 try{
549 salt.enforceState(master, 'I@gerrit:client', 'gerrit', true)
550 }catch(e){
551 salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.refresh_pillar', [], null, true)
552 salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.sync_all', [], null, true)
553 throw e //rethrow for retry handler
554 }
555 }
556 retry(2){
557 try{
558 salt.enforceState(master, 'I@jenkins:client', 'jenkins', true)
559 }catch(e){
560 salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.refresh_pillar', [], null, true)
561 salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.sync_all', [], null, true)
562 throw e //rethrow for retry handler
563 }
564 }
565 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200566}
567
568
Martin Polreich8663a342017-06-30 17:33:08 +0200569def installStacklight(master) {
570 def common = new com.mirantis.mk.Common()
571 def salt = new com.mirantis.mk.Salt()
572
Simon Pasquieref4122c2017-08-25 15:52:07 +0200573 // Install core services for K8S environments:
574 // HAProxy, Nginx and lusterFS clients
575 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200576 if (common.checkContains('STACK_INSTALL', 'k8s')) {
577 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
578 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200579
580 if (salt.testTarget(master, 'I@nginx:server')) {
581 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
582 }
583
584 if (salt.testTarget(master, 'I@glusterfs:client')) {
585 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true)
586 }
Martin Polreich792f2662017-07-11 13:36:32 +0200587 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200588
589 // Launch containers
590 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client', true)
591 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps', [], null, true)
592
Martin Polreich8663a342017-06-30 17:33:08 +0200593 //Install Telegraf
Martin Polreichd894e3e2017-07-04 15:35:02 +0200594 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200595
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400596 // Install Prometheus exporters
597 if (salt.testTarget(master, 'I@prometheus:exporters')) {
598 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus', true)
599 }
600
Martin Polreich8663a342017-06-30 17:33:08 +0200601 //Install Elasticsearch and Kibana
Martin Polreichbf7f6162017-07-06 14:43:21 +0200602 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200603 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200604 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200605 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
Martin Polreicha540ac12017-06-30 22:48:39 +0200606 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200607 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Martin Polreichbf7f6162017-07-06 14:43:21 +0200608 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200609 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
610
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200611 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
612
Ondrej Smola5908ae62018-01-08 13:42:08 +0100613 // Install heka ceilometer collector
614 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
615 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector', true)
616 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
617 }
618
Martin Polreich470925a2017-07-06 17:12:59 +0200619 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200620 if (common.checkContains('STACK_INSTALL', 'k8s')) {
621 withEnv(['ASK_ON_ERROR=false']){
622 retry(2) {
623 salt.enforceState(master, 'I@galera:master', 'galera', true)
624 }
Martin Polreich470925a2017-07-06 17:12:59 +0200625 }
Martin Polreich792f2662017-07-11 13:36:32 +0200626 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Martin Polreich406f6462017-07-11 11:33:42 +0000627
Martin Polreich792f2662017-07-11 13:36:32 +0200628 // Check galera status
629 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
630 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
631 }
Martin Polreich470925a2017-07-06 17:12:59 +0200632
Martin Polreich8663a342017-06-30 17:33:08 +0200633 //Collect Grains
634 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains', true)
635 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules', [], null, true)
636 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update', [], null, true)
637 sleep(5)
638
639 //Configure services in Docker Swarm
Martin Polreich8017f452017-08-21 16:01:42 +0200640 if (common.checkContains('STACK_INSTALL', 'k8s')) {
641 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false)
642 }
643 else {
644 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false)
645 }
Martin Polreich8663a342017-06-30 17:33:08 +0200646
647 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200648 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200649 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200650
Martin Polreich8663a342017-06-30 17:33:08 +0200651 def stacklight_vip
652 if(!pillar['return'].isEmpty()) {
653 stacklight_vip = pillar['return'][0].values()[0]
654 } else {
655 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
656 }
vrovachev1c4770b2017-07-05 13:25:21 +0400657
Martin Polreich305e2222017-07-06 11:33:00 +0200658 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200659 sleep(120)
Martin Polreich8663a342017-06-30 17:33:08 +0200660 salt.enforceState(master, 'I@grafana:client', 'grafana.client', true)
Martin Polreich8663a342017-06-30 17:33:08 +0200661}
662
663def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200664 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200665
666 // infra install
667 // Install the StackLight backends
668 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
669 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
670
671 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
672 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
673
674 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
675 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
676
677 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
678 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
679
Kalynovskyi3e370112017-06-26 12:48:23 +0300680 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
681 def alarming_service = alarming_service_pillar['return'][0].values()[0]
682
683 switch (alarming_service) {
684 case 'sensu':
685 // Update Sensu
686 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true)
687 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true)
688 salt.enforceState(master, 'I@redis:server', 'redis', true)
689 salt.enforceState(master, 'I@sensu:server', 'sensu', true)
690 default:
691 // Update Nagios
692 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
693 // Stop the Nagios service because the package starts it by default and it will
694 // started later only on the node holding the VIP address
695 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
696 }
697
Ales Komarekef2bab62017-04-26 11:48:28 +0200698 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
Marek Celoudebc623b2017-06-02 17:12:31 +0200699 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200700
701 sleep(10)
702}
703
Martin Polreich8663a342017-06-30 17:33:08 +0200704def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200705 def salt = new com.mirantis.mk.Salt()
706 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200707
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200708 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200709 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200710 salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200711 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
712
713 // Install collectd, heka and sensu services on the nodes, this will also
714 // generate the metadata that goes into the grains and eventually into Salt Mine
715 salt.enforceState(master, '*', 'collectd', true)
716 salt.enforceState(master, '*', 'salt.minion', true)
717 salt.enforceState(master, '*', 'heka', true)
718
719 // Gather the Grafana metadata as grains
720 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
721
722 // Update Salt Mine
723 salt.enforceState(master, '*', 'salt.minion.grains', true)
724 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
725 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
726
727 sleep(5)
728
729 // Update Heka
730 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
731
732 // Update collectd
733 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
734
Kalynovskyi3e370112017-06-26 12:48:23 +0300735 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
736 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200737
Kalynovskyi3e370112017-06-26 12:48:23 +0300738 switch (alarming_service) {
739 case 'sensu':
740 // Update Sensu
741 // TODO for stacklight team, should be fixed in model
742 salt.enforceState(master, 'I@sensu:client', 'sensu', true)
743 default:
744 break
745 // Default is nagios, and was enforced in installStacklightControl()
746 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200747
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200748 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 +0200749 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
750
Marek Celoudd200cad2017-06-07 10:34:46 +0200751 // Finalize the configuration of Grafana (add the dashboards...)
Alexander Noskov8448fc52017-06-21 14:03:45 +0200752 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
753 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true)
754 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true)
Marek Celoudd200cad2017-06-07 10:34:46 +0200755 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
756
Ales Komarekef2bab62017-04-26 11:48:28 +0200757 // Get the StackLight monitoring VIP addres
758 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
759 //vip=${vip:=172.16.10.253}
760 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200761 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200762 def stacklight_vip = pillar['return'][0].values()[0]
763
764 if (stacklight_vip) {
765 // (re)Start manually the services that are bound to the monitoring VIP
766 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
767 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
768 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
769 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
770 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
771 } else {
772 throw new Exception("Missing stacklight_vip")
773 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100774}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200775
776
777//
778// Ceph
779//
780
Tomáš Kukráled27a472017-08-29 10:26:25 +0200781def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200782 def salt = new com.mirantis.mk.Salt()
783
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200784 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains', true)
785
Jiri Broulike57a0242017-10-06 13:38:47 +0200786 // generate keyrings
787 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
788 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200789 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200790 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 +0200791 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200792 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200793 // install Ceph Mons
Tomáš Kukrál9b4fb512017-08-14 11:01:49 +0200794 salt.enforceState(master, target, 'ceph.mon', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200795 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200796 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr', true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200797 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200798}
799
Tomáš Kukráled27a472017-08-29 10:26:25 +0200800def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200801 def salt = new com.mirantis.mk.Salt()
802
803 // install Ceph OSDs
804 salt.enforceState(master, target, 'ceph.osd', true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200805 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200806 salt.enforceState(master, target, 'ceph.osd.custom', true)
Jiri Broulik2911deb2017-10-12 20:26:43 +0200807 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true)
808 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update', [], null, true)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200809
Jiri Broulike57a0242017-10-06 13:38:47 +0200810 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200811 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200812 sleep(5)
Tomáš Kukráled27a472017-08-29 10:26:25 +0200813 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup', true)
814 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200815}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200816
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200817def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200818 def salt = new com.mirantis.mk.Salt()
819
820 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200821 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200822 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains', [], null, true)
Tomáš Kukrál1fe90452017-08-28 18:27:26 +0200823 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw', true)
Alexander Noskov229035f2017-12-06 00:10:20 +0400824 }
825 // setup Keystone service and endpoints for swift or / and S3
826 if (salt.testTarget(master, 'I@keystone:client')) {
Jiri Broulik831a74e2017-10-18 08:27:11 +0200827 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200828 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200829}
Jiri Broulike57a0242017-10-06 13:38:47 +0200830
831def connectCeph(master) {
832 def salt = new com.mirantis.mk.Salt()
833
834 // connect Ceph to the env
835 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
836 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'], true)
837 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
838 }
839 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
840 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'], true)
841 }
842 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
843 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'], true)
Jiri Broulik07f8de72017-10-09 14:12:17 +0200844 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains', [], null, true)
Jiri Broulike57a0242017-10-06 13:38:47 +0200845 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'], true)
846 }
847}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400848
849def installOssInfra(master) {
850 def common = new com.mirantis.mk.Common()
851 def salt = new com.mirantis.mk.Salt()
852
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400853 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400854 def orchestrate = new com.mirantis.mk.Orchestrate()
855 orchestrate.installInfra(master)
856 }
857
858 if (salt.testTarget(master, 'I@devops_portal:config')) {
859 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config', true)
860 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'], true)
861 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server', true)
862 }
863}
864
865def installOss(master) {
866 def common = new com.mirantis.mk.Common()
867 def salt = new com.mirantis.mk.Salt()
868
869 //Get oss VIP address
870 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
871 common.prettyPrint(pillar)
872
873 def oss_vip
874 if(!pillar['return'].isEmpty()) {
875 oss_vip = pillar['return'][0].values()[0]
876 } else {
877 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
878 }
879
880 // Postgres client - initialize OSS services databases
881 timeout(120){
882 common.infoMsg("Waiting for postgresql database to come up..")
883 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')
884 }
885 // XXX: first run usually fails on some inserts, but we need to create databases at first
886 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
887
888 // Setup postgres database with integration between
889 // Pushkin notification service and Security Monkey security audit service
890 timeout(10) {
891 common.infoMsg("Waiting for Pushkin to come up..")
892 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
893 }
894 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true)
895
896 // Rundeck
897 timeout(10) {
898 common.infoMsg("Waiting for Rundeck to come up..")
899 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
900 }
901 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client', true)
902
903 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +0400904 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
905 def elasticsearch_vip
906 if(!pillar['return'].isEmpty()) {
907 elasticsearch_vip = pillar['return'][0].values()[0]
908 } else {
909 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
910 }
911
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400912 timeout(10) {
913 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +0400914 salt.cmdRun(master, 'I@elasticsearch:client', "while true; do curl -sf ${elasticsearch_vip}:9200 >/dev/null && break; done")
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400915 }
916 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
917}