blob: 5ec8a782d6d1749ffb1ac640392d1bc5060c2154 [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
Jakub Josef432e9d92018-02-06 18:28:37 +010010 salt.cmdRun(master, 'I@salt:master' ,'salt-key')
11 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version')
12 salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top')
13 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory')
14 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top')
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.
Jakub Josef432e9d92018-02-06 18:28:37 +010023 salt.enforceState(master, 'I@salt:master', ['reclass'])
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020024
Jakub Josef432e9d92018-02-06 18:28:37 +010025 salt.enforceState(master, 'I@salt:master', ['linux.system'])
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020026 salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010027 salt.fullRefresh(master, "*")
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020028
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030029 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010030 salt.enforceState(master, 'I@salt:master', ['salt.minion'])
31 salt.fullRefresh(master, "*")
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020032
Jakub Josef432e9d92018-02-06 18:28:37 +010033 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010034 if (staticMgmtNet) {
35 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
36 }
Jakub Josef432e9d92018-02-06 18:28:37 +010037 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020038 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020039 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +010040 salt.enforceState(master, '*', ['linux.network.host'])
Jakub Josef79ecec32017-02-17 14:36:28 +010041}
42
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010043def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020044 def salt = new com.mirantis.mk.Salt()
45
46 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010047 salt.fullRefresh(master, target)
48 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010049 if (staticMgmtNet) {
50 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
51 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020052 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010053 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020054
Jakub Josef432e9d92018-02-06 18:28:37 +010055 salt.enforceState(master, target, ['linux', 'openssh', 'ntp'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020056 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +010057 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020058}
59
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010060def installInfraKvm(master) {
61 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010062 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020063
Richard Felkl286f25f2017-07-26 14:23:55 +020064 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010065 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp'])
66 salt.enforceState(master, 'I@salt:control', 'libvirt')
67 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010068
Ales Komarekef2bab62017-04-26 11:48:28 +020069 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010070
Jakub Josef432e9d92018-02-06 18:28:37 +010071 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010072}
Jakub Josef79ecec32017-02-17 14:36:28 +010073
vrovachev1c4770b2017-07-05 13:25:21 +040074def installInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010075 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020076
Jakub Josef79ecec32017-02-17 14:36:28 +010077 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020078 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010079 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010080
Jakub Josef432e9d92018-02-06 18:28:37 +010081 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
82 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +020083 }
Ales Komarekef2bab62017-04-26 11:48:28 +020084
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030085 // Ensure glusterfs clusters is ready
86 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010087 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030088 }
89
Jakub Josef79ecec32017-02-17 14:36:28 +010090 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +020091 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010092 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +040093
94 // Check galera status
95 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
96 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +030097 // If galera is not enabled check if we need to install mysql:server
98 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +010099 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300100 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100101 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300102 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200103 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200104
vrovachev1c4770b2017-07-05 13:25:21 +0400105 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200106 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400107 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200108 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400109 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200110
vrovachev1c4770b2017-07-05 13:25:21 +0400111 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200112 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100113 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
114 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400115 }
116
117 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200118 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100119 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400120
121 // Check the rabbitmq status
Jakub Josef432e9d92018-02-06 18:28:37 +0100122 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
vrovachev1c4770b2017-07-05 13:25:21 +0400123 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200124
Jakub Josef79ecec32017-02-17 14:36:28 +0100125 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200126 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100127 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400128 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
129 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
130 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200131
Jakub Josef79ecec32017-02-17 14:36:28 +0100132 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200133 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100134 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400135 }
136
137 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200138 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400139 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
vrovachev076e5c92017-11-13 18:56:17 +0400140 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
vrovachev1c4770b2017-07-05 13:25:21 +0400141 }
142}
143
144def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100145 def common = new com.mirantis.mk.Common()
146 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
147 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100148}
149
150
Ales Komarekef2bab62017-04-26 11:48:28 +0200151def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100152 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200153
154 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300155 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100156 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300157 }
158 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100159 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
160 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300161 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200162
Jakub Josef79ecec32017-02-17 14:36:28 +0100163 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300164 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100165 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
166 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300167 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100168
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300169 // keystone:client must be called locally
170 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
171 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
172 sleep(30)
173 }
174 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100175 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
176 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300177 }
178 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100179 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300180 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100181
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300182 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300183 if (salt.testTarget(master, 'I@glance:server')) {
184 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100185 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
186 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300187 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200188
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300189 // Check glance service
190 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100191 salt.cmdRun(master, 'I@keystone:server','. /root/keystonerc; glance image-list')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300192 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200193
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400194 // Create glance resources
195 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100196 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400197 }
198
Jakub Josef79ecec32017-02-17 14:36:28 +0100199 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300200 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100201 // run on first node first
202 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
203 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300204 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100205 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; nova service-list')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 }
207 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200208
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400209 // Create nova resources
210 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100211 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400212 }
213
Jakub Josef79ecec32017-02-17 14:36:28 +0100214 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300215 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100216 // run on first node first
217 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
218 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300219 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100220 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; cinder list')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300221 }
222 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200223
Jakub Josef79ecec32017-02-17 14:36:28 +0100224 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300225 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100226 // run on first node first
227 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
228 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300229 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100230 salt.cmdRun(master, 'I@keystone:server','. /root/keystonerc; neutron agent-list')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300231 }
232 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200233
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400234 // Create neutron resources
235 if (salt.testTarget(master, 'I@neutron:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100236 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400237 }
238
Jakub Josef79ecec32017-02-17 14:36:28 +0100239 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300240 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100241 // run on first node first
242 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
243 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300244 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef3e261b92018-02-08 14:25:05 +0100245 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; heat resource-type-list', false)
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300246 }
247 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200248
249 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300250 if (salt.testTarget(master, 'I@nova:controller')) {
251 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
252 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300253
254 // Install ironic service
255 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100256 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
257 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300258 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300259
260 // Install designate service
261 if (salt.testTarget(master, 'I@designate:server:enabled')) {
262 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100263 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300264 }
265 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100266 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300267 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100268 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
269 salt.enforceState(master, 'I@designate:server', 'designate.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300270 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400271
272 // Install octavia api service
273 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100274 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100275 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400276 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200277
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200278 // Install DogTag server service
279 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100280 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
281 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200282 }
283
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200284 // Install barbican server service
285 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100286 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
287 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200288 }
289 // Install barbican client
290 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100291 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200292 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100293
294 // Install ceilometer server
295 if (salt.testTarget(master, 'I@ceilometer:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100296 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100297 }
298
299 // Install aodh server
300 if (salt.testTarget(master, 'I@aodh:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100301 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100302 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100303}
304
305
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300306def installIronicConductor(master){
307 def salt = new com.mirantis.mk.Salt()
308
309 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100310 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
311 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300312 }
313 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100314 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300315 }
316
317 if (salt.testTarget(master, 'I@nova:compute')) {
318 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
319 }
320
321 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100322 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300323 }
324 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100325 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300326 }
327}
328
329
330
Ales Komarekef2bab62017-04-26 11:48:28 +0200331def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100332 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200333
Jakub Josef432e9d92018-02-06 18:28:37 +0100334 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400335
336 // install octavia manager services
337 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100338 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
339 salt.enforceState(master, 'I@octavia:manager', 'octavia')
340 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
341 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400342 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200343}
344
345
346def installOpenstackCompute(master) {
347 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200348 // Configure compute nodes
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200349 if (salt.testTarget(master, 'I@nova:compute')) {
350 retry(2) {
351 salt.enforceHighstateWithExclude(master, 'I@nova:compute', 'opencontrail.client')
352 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200353 }
354}
355
356
357def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200358 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200359 def salt = new com.mirantis.mk.Salt()
360
361
Jakub Josef79ecec32017-02-17 14:36:28 +0100362 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100363 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
364 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200365
Jakub Josef79ecec32017-02-17 14:36:28 +0100366 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100367 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
368 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
369 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100370
Marek Celoud443fb642017-11-22 15:07:12 +0100371 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100372 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100373 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100374}
375
376
Ales Komarekef2bab62017-04-26 11:48:28 +0200377def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200378 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400379 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100380 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200381 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100382 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100383 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100384
vrovachev4ff77302017-08-09 20:39:57 +0400385 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200386 if (salt.testTarget(master, 'I@opencontrail:compute')) {
387 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
388 }
vrovachev4ff77302017-08-09 20:39:57 +0400389
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200390 if (salt.testTarget(master, 'I@nova:compute')) {
391 salt.cmdRun(master, 'I@nova:compute', 'exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "', false)
392 }
vrovachev4ff77302017-08-09 20:39:57 +0400393
394 if (salt.testTarget(master, 'I@opencontrail:compute')) {
395 sleep(300)
Jakub Josef432e9d92018-02-06 18:28:37 +0100396 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
397 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400398 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100399}
400
401
Ales Komarekef2bab62017-04-26 11:48:28 +0200402def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100403 def common = new com.mirantis.mk.Common()
404 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
405 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100406}
407
408
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200409def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100410 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200411
Jakub Josef79ecec32017-02-17 14:36:28 +0100412 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200413 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
414 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100415
Marek Celoud029391c2017-11-14 10:06:18 +0100416 if (salt.testTarget(master, 'I@etcd:server:setup')) {
417 // Setup etcd server
418 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
419 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100420
421 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100422 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100423
424 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200425 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100426
427 // Restart kubelet
428 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
429}
430
431
Ales Komarekef2bab62017-04-26 11:48:28 +0200432def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200433 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100434 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200435
436 // Bootstrap all nodes
437 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
438 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
439 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
440
441 // Create and distribute SSL certificates for services using salt state
442 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
443
444 // Install docker
445 salt.enforceState(master, 'I@docker:host', 'docker.host')
446
447 // Install Kubernetes and Calico
448 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
449
Yuriy Taradayab564d72017-10-11 15:14:35 +0400450 // Install Tiller and all configured releases
451 if (salt.testTarget(master, 'I@helm:client')) {
452 salt.enforceState(master, 'I@helm:client', 'helm')
453 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200454}
455
456
Martin Polreich8663a342017-06-30 17:33:08 +0200457def installDockerSwarm(master) {
458 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100459
vrovachev1c4770b2017-07-05 13:25:21 +0400460 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200461 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100462 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
463 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
464 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
465 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200466 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100467 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
468 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
469 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200470}
471
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200472
473def installCicd(master) {
474 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100475 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100476
Richard Felklc1aba9b2018-01-02 09:25:20 +0100477 if (salt.testTarget(master, 'I@aptly:publisher')) {
478 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
479 }
480
Richard Felkl6de16762017-11-20 11:42:28 +0100481 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 +0200482 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100483
484 if (salt.testTarget(master, 'I@aptly:server')) {
485 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
486 }
487
488 if (salt.testTarget(master, 'I@openldap:client')) {
489 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
490 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200491
492 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100493 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200494 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100495
Richard Felkl6e208fc2017-12-08 10:18:44 +0100496 withEnv(['ASK_ON_ERROR=false']){
497 retry(2){
498 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100499 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100500 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100501 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100502 throw e //rethrow for retry handler
503 }
504 }
505 retry(2){
506 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100507 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100508 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100509 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100510 throw e //rethrow for retry handler
511 }
512 }
513 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200514}
515
516
Martin Polreich8663a342017-06-30 17:33:08 +0200517def installStacklight(master) {
518 def common = new com.mirantis.mk.Common()
519 def salt = new com.mirantis.mk.Salt()
520
Simon Pasquieref4122c2017-08-25 15:52:07 +0200521 // Install core services for K8S environments:
522 // HAProxy, Nginx and lusterFS clients
523 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200524 if (common.checkContains('STACK_INSTALL', 'k8s')) {
525 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
526 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200527
528 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100529 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200530 }
531
532 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100533 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200534 }
Martin Polreich792f2662017-07-11 13:36:32 +0200535 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200536
537 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100538 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
539 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200540
Martin Polreich8663a342017-06-30 17:33:08 +0200541 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100542 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200543
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400544 // Install Prometheus exporters
545 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100546 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400547 }
548
Martin Polreich8663a342017-06-30 17:33:08 +0200549 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100550 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
551 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
552 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
553 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
554 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
555 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
556 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
557 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Martin Polreich8663a342017-06-30 17:33:08 +0200558
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200559 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
560
Ondrej Smola5908ae62018-01-08 13:42:08 +0100561 // Install heka ceilometer collector
562 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100563 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100564 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
565 }
566
Martin Polreich470925a2017-07-06 17:12:59 +0200567 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200568 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100569 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
570 salt.enforceState(master, 'I@galera:slave', 'galera')
Martin Polreich406f6462017-07-11 11:33:42 +0000571
Martin Polreich792f2662017-07-11 13:36:32 +0200572 // Check galera status
573 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
574 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
575 }
Martin Polreich470925a2017-07-06 17:12:59 +0200576
Martin Polreich8663a342017-06-30 17:33:08 +0200577 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100578 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
579 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
580 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200581 sleep(5)
582
583 //Configure services in Docker Swarm
Martin Polreich8017f452017-08-21 16:01:42 +0200584 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100585 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false)
586 } else {
587 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200588 }
Martin Polreich8663a342017-06-30 17:33:08 +0200589
590 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200591 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200592 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200593
Martin Polreich8663a342017-06-30 17:33:08 +0200594 def stacklight_vip
595 if(!pillar['return'].isEmpty()) {
596 stacklight_vip = pillar['return'][0].values()[0]
597 } else {
598 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
599 }
vrovachev1c4770b2017-07-05 13:25:21 +0400600
Martin Polreich305e2222017-07-06 11:33:00 +0200601 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200602 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100603 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200604}
605
606def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200607 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200608
609 // infra install
610 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100611 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
612 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200613
Jakub Josef432e9d92018-02-06 18:28:37 +0100614 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
615 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200616
Jakub Josef432e9d92018-02-06 18:28:37 +0100617 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
618 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200619
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
621 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200622
Kalynovskyi3e370112017-06-26 12:48:23 +0300623 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
624 def alarming_service = alarming_service_pillar['return'][0].values()[0]
625
626 switch (alarming_service) {
627 case 'sensu':
628 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100629 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
630 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
631 salt.enforceState(master, 'I@redis:server', 'redis')
632 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300633 default:
634 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100635 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300636 // Stop the Nagios service because the package starts it by default and it will
637 // started later only on the node holding the VIP address
638 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
639 }
640
Jakub Josef432e9d92018-02-06 18:28:37 +0100641 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
642 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200643
644 sleep(10)
645}
646
Martin Polreich8663a342017-06-30 17:33:08 +0200647def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200648 def salt = new com.mirantis.mk.Salt()
649 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200650
Jakub Josef432e9d92018-02-06 18:28:37 +0100651 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200652 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100653 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200654 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
655
656 // Install collectd, heka and sensu services on the nodes, this will also
657 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100658 salt.enforceState(master, '*', 'collectd')
659 salt.enforceState(master, '*', 'salt.minion')
660 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200661
662 // Gather the Grafana metadata as grains
663 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
664
665 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100666 salt.enforceState(master, '*', 'salt.minion.grains')
667 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
668 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200669
670 sleep(5)
671
672 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100673 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200674
675 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100676 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200677
Kalynovskyi3e370112017-06-26 12:48:23 +0300678 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
679 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200680
Kalynovskyi3e370112017-06-26 12:48:23 +0300681 switch (alarming_service) {
682 case 'sensu':
683 // Update Sensu
684 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100685 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300686 default:
687 break
688 // Default is nagios, and was enforced in installStacklightControl()
689 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200690
Jakub Josef432e9d92018-02-06 18:28:37 +0100691 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200692 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
693
Marek Celoudd200cad2017-06-07 10:34:46 +0200694 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100695 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
696 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
697 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200698 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
699
Ales Komarekef2bab62017-04-26 11:48:28 +0200700 // Get the StackLight monitoring VIP addres
701 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
702 //vip=${vip:=172.16.10.253}
703 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200704 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200705 def stacklight_vip = pillar['return'][0].values()[0]
706
707 if (stacklight_vip) {
708 // (re)Start manually the services that are bound to the monitoring VIP
709 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100710 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
711 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
712 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
713 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200714 } else {
715 throw new Exception("Missing stacklight_vip")
716 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100717}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200718
719
720//
721// Ceph
722//
723
Tomáš Kukráled27a472017-08-29 10:26:25 +0200724def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200725 def salt = new com.mirantis.mk.Salt()
726
Jakub Josef432e9d92018-02-06 18:28:37 +0100727 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200728
Jiri Broulike57a0242017-10-06 13:38:47 +0200729 // generate keyrings
730 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100731 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
732 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
733 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200734 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200735 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200736 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100737 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200738 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100739 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200740 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200741}
742
Tomáš Kukráled27a472017-08-29 10:26:25 +0200743def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200744 def salt = new com.mirantis.mk.Salt()
745
746 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100747 salt.enforceState(master, target, 'ceph.osd')
748 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
749 salt.enforceState(master, target, 'ceph.osd.custom')
750 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
751 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200752
Jiri Broulike57a0242017-10-06 13:38:47 +0200753 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200754 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200755 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100756 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200757 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200758}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200759
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200760def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200761 def salt = new com.mirantis.mk.Salt()
762
763 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200764 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100765 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
766 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400767 }
768 // setup Keystone service and endpoints for swift or / and S3
769 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100770 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200771 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200772}
Jiri Broulike57a0242017-10-06 13:38:47 +0200773
774def connectCeph(master) {
775 def salt = new com.mirantis.mk.Salt()
776
777 // connect Ceph to the env
778 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100779 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200780 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
781 }
782 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100783 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200784 }
785 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100786 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
787 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
788 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200789 }
790}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400791
792def installOssInfra(master) {
793 def common = new com.mirantis.mk.Common()
794 def salt = new com.mirantis.mk.Salt()
795
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400796 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400797 def orchestrate = new com.mirantis.mk.Orchestrate()
798 orchestrate.installInfra(master)
799 }
800
801 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100802 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
803 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
804 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400805 }
806}
807
808def installOss(master) {
809 def common = new com.mirantis.mk.Common()
810 def salt = new com.mirantis.mk.Salt()
811
812 //Get oss VIP address
813 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
814 common.prettyPrint(pillar)
815
816 def oss_vip
817 if(!pillar['return'].isEmpty()) {
818 oss_vip = pillar['return'][0].values()[0]
819 } else {
820 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
821 }
822
823 // Postgres client - initialize OSS services databases
824 timeout(120){
825 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -0600826 salt.cmdRun(master, 'I@postgresql:client', 'while true; do if docker service logs postgresql_postgresql-db 2>&1 | grep "ready to accept"; then break; else sleep 5; fi; done')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400827 }
828 // XXX: first run usually fails on some inserts, but we need to create databases at first
829 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
830
831 // Setup postgres database with integration between
832 // Pushkin notification service and Security Monkey security audit service
833 timeout(10) {
834 common.infoMsg("Waiting for Pushkin to come up..")
835 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
836 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100837 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400838
839 // Rundeck
840 timeout(10) {
841 common.infoMsg("Waiting for Rundeck to come up..")
842 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
843 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100844 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400845
846 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +0400847 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
848 def elasticsearch_vip
849 if(!pillar['return'].isEmpty()) {
850 elasticsearch_vip = pillar['return'][0].values()[0]
851 } else {
852 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
853 }
854
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400855 timeout(10) {
856 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +0400857 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 +0400858 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100859 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400860}