blob: 8fde788e34fa6fc17207c91a35431aa585b4e16e [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 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +010037 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
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
Jiri Broulike3e7bc32018-02-26 10:50:07 +010055 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
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)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010065 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010066 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 Josef61463c72018-02-13 16:10:56 +010075 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010076 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020077
Jakub Josef79ecec32017-02-17 14:36:28 +010078 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020079 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010080 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010081
Jakub Josef432e9d92018-02-06 18:28:37 +010082 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +010083 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +010084 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +020085 }
Ales Komarekef2bab62017-04-26 11:48:28 +020086
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030087 // Ensure glusterfs clusters is ready
88 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010089 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030090 }
91
Jakub Josef79ecec32017-02-17 14:36:28 +010092 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +020093 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010094 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +040095
96 // Check galera status
97 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
98 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +030099 // If galera is not enabled check if we need to install mysql:server
100 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100101 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300102 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100103 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300104 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200105 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100106 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200107
vrovachev1c4770b2017-07-05 13:25:21 +0400108 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200109 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400110 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200111 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400112 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200113
vrovachev1c4770b2017-07-05 13:25:21 +0400114 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200115 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100116 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
117 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400118 }
119
120 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200121 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100122 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400123
124 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100125 common.retry(3,5){
126 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
127 }
vrovachev1c4770b2017-07-05 13:25:21 +0400128 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200129
Jakub Josef79ecec32017-02-17 14:36:28 +0100130 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200131 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100132 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400133 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
134 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
135 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200136
Jakub Josef79ecec32017-02-17 14:36:28 +0100137 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200138 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100139 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400140 }
141
142 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200143 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400144 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100145 common.retry(3,5){
146 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
147 }
vrovachev1c4770b2017-07-05 13:25:21 +0400148 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200149
150 // Install redis
151 if (salt.testTarget(master, 'I@redis:server')) {
152 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
153 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
154 }
155 salt.enforceState(master, 'I@redis:server', 'redis')
156 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100157 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400158}
159
160def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100161 def common = new com.mirantis.mk.Common()
162 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
163 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100164}
165
166
Ales Komarekef2bab62017-04-26 11:48:28 +0200167def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100168 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100169 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200170
171 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300172 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100173 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300174 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100175 // Install sphinx server
176 if (salt.testTarget(master, 'I@sphinx:server')) {
177 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
178 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300179 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100180 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
181 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300182 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200183
Jakub Josef79ecec32017-02-17 14:36:28 +0100184 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300185 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100186 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
187 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300188 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100189
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300190 // keystone:client must be called locally
191 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
192 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
193 sleep(30)
194 }
195 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100196 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
197 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300198 }
199 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100200 common.retry(3,5){
201 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
202 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300203 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100204
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300205 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 if (salt.testTarget(master, 'I@glance:server')) {
207 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100208 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
209 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300210 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200211
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300212 // Check glance service
213 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100214 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200215 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100216 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300217 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200218
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400219 // Create glance resources
220 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100221 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400222 }
223
Jakub Josef79ecec32017-02-17 14:36:28 +0100224 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300225 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100226 // run on first node first
227 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
228 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300229 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100230 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200231 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100232 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300233 }
234 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200235
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400236 // Create nova resources
237 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100238 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400239 }
240
Jakub Josef79ecec32017-02-17 14:36:28 +0100241 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300242 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100243 // run on first node first
244 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
245 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300246 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100247 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200248 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100249 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300250 }
251 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200252
Jakub Josef79ecec32017-02-17 14:36:28 +0100253 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300254 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100255 // run on first node first
256 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
257 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300258 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100259 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200260 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100261 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300262 }
263 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200264
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400265 // Create neutron resources
266 if (salt.testTarget(master, 'I@neutron:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100267 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400268 }
269
Jakub Josef79ecec32017-02-17 14:36:28 +0100270 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300271 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100272 // run on first node first
273 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
274 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300275 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100276 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200277 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100278 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300279 }
280 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200281
282 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300283 if (salt.testTarget(master, 'I@nova:controller')) {
284 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
285 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300286
287 // Install ironic service
288 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100289 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
290 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300291 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300292
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200293 // Install manila service
294 if (salt.testTarget(master, 'I@manila:api')) {
295 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
296 salt.enforceState(master, 'I@manila:api', 'manila.api')
297 }
298 if (salt.testTarget(master, 'I@manila:scheduler')) {
299 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
300 }
301
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300302 // Install designate service
303 if (salt.testTarget(master, 'I@designate:server:enabled')) {
304 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100305 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300306 }
307 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100308 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300309 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100310 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
311 salt.enforceState(master, 'I@designate:server', 'designate.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300312 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400313
314 // Install octavia api service
315 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100316 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100317 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400318 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200319
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200320 // Install DogTag server service
321 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100322 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
323 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200324 }
325
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200326 // Install barbican server service
327 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100328 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
329 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200330 }
331 // Install barbican client
332 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100333 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200334 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100335
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200336 // Install gnocchi server
337 if (salt.testTarget(master, 'I@gnocchi:server')) {
338 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
339 }
340
341 // Install gnocchi statsd
342 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
343 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
344 }
345
346 // Install panko server
347 if (salt.testTarget(master, 'I@panko:server')) {
348 salt.enforceState(master, 'I@panko:server', 'panko')
349 }
350
Ondrej Smola5908ae62018-01-08 13:42:08 +0100351 // Install ceilometer server
352 if (salt.testTarget(master, 'I@ceilometer:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100353 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100354 }
355
356 // Install aodh server
357 if (salt.testTarget(master, 'I@aodh:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100358 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100359 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100360}
361
362
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300363def installIronicConductor(master){
364 def salt = new com.mirantis.mk.Salt()
365
366 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100367 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
368 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300369 }
370 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100371 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300372 }
373
374 if (salt.testTarget(master, 'I@nova:compute')) {
375 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
376 }
377
378 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100379 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300380 }
381 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100382 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300383 }
384}
385
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200386def installManilaShare(master){
387 def salt = new com.mirantis.mk.Salt()
388
389 if (salt.testTarget(master, 'I@manila:share')) {
390 salt.enforceState(master, 'I@manila:share', 'manila.share')
391 }
392 if (salt.testTarget(master, 'I@manila:data')) {
393 salt.enforceState(master, 'I@manila:data', 'manila.data')
394 }
395
396 if (salt.testTarget(master, 'I@manila:client')) {
397 salt.enforceState(master, 'I@manila:client', 'manila.client')
398 }
399}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300400
401
Ales Komarekef2bab62017-04-26 11:48:28 +0200402def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100403 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200404
Jakub Josef432e9d92018-02-06 18:28:37 +0100405 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400406
407 // install octavia manager services
408 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100409 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
410 salt.enforceState(master, 'I@octavia:manager', 'octavia')
411 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
412 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400413 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200414}
415
416
417def installOpenstackCompute(master) {
418 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200419 // Configure compute nodes
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200420 if (salt.testTarget(master, 'I@nova:compute')) {
421 retry(2) {
422 salt.enforceHighstateWithExclude(master, 'I@nova:compute', 'opencontrail.client')
423 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200424 }
425}
426
427
428def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200429 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200430 def salt = new com.mirantis.mk.Salt()
431
432
Jakub Josef79ecec32017-02-17 14:36:28 +0100433 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100434 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
435 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200436
Jakub Josef79ecec32017-02-17 14:36:28 +0100437 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100438 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
439 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
440 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100441
Marek Celoud443fb642017-11-22 15:07:12 +0100442 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100443 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100444 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100445 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100446}
447
448
Ales Komarekef2bab62017-04-26 11:48:28 +0200449def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200450 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400451 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100452 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200453 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100454 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100455 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100456
vrovachev4ff77302017-08-09 20:39:57 +0400457 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200458 if (salt.testTarget(master, 'I@opencontrail:compute')) {
459 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
460 }
vrovachev4ff77302017-08-09 20:39:57 +0400461
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200462 if (salt.testTarget(master, 'I@nova:compute')) {
463 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)
464 }
vrovachev4ff77302017-08-09 20:39:57 +0400465
Jakub Josef61463c72018-02-13 16:10:56 +0100466 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400467 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100468 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
469 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400470 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100471}
472
473
Ales Komarekef2bab62017-04-26 11:48:28 +0200474def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100475 def common = new com.mirantis.mk.Common()
476 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
477 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100478}
479
480
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200481def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100482 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200483
Jakub Josef79ecec32017-02-17 14:36:28 +0100484 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200485 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
486 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100487
Marek Celoud029391c2017-11-14 10:06:18 +0100488 if (salt.testTarget(master, 'I@etcd:server:setup')) {
489 // Setup etcd server
490 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
491 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100492
493 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100494 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100495
496 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200497 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100498
499 // Restart kubelet
500 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
501}
502
503
Ales Komarekef2bab62017-04-26 11:48:28 +0200504def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200505 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100506 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200507
508 // Bootstrap all nodes
509 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
510 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
511 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
512
513 // Create and distribute SSL certificates for services using salt state
514 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
515
516 // Install docker
517 salt.enforceState(master, 'I@docker:host', 'docker.host')
518
519 // Install Kubernetes and Calico
520 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
521
Yuriy Taradayab564d72017-10-11 15:14:35 +0400522 // Install Tiller and all configured releases
523 if (salt.testTarget(master, 'I@helm:client')) {
524 salt.enforceState(master, 'I@helm:client', 'helm')
525 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200526}
527
528
Martin Polreich8663a342017-06-30 17:33:08 +0200529def installDockerSwarm(master) {
530 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100531
vrovachev1c4770b2017-07-05 13:25:21 +0400532 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200533 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100534 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
535 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
536 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
537 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200538 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100539 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
540 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100541 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100542 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200543}
544
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200545
546def installCicd(master) {
547 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100548 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100549
Richard Felklc1aba9b2018-01-02 09:25:20 +0100550 if (salt.testTarget(master, 'I@aptly:publisher')) {
551 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
552 }
553
Richard Felkl6de16762017-11-20 11:42:28 +0100554 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 +0200555 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100556
557 if (salt.testTarget(master, 'I@aptly:server')) {
558 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
559 }
560
561 if (salt.testTarget(master, 'I@openldap:client')) {
562 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
563 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200564
565 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100566 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200567 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100568
Richard Felkl6e208fc2017-12-08 10:18:44 +0100569 withEnv(['ASK_ON_ERROR=false']){
570 retry(2){
571 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100572 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100573 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100574 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100575 throw e //rethrow for retry handler
576 }
577 }
578 retry(2){
579 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100580 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100581 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100582 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100583 throw e //rethrow for retry handler
584 }
585 }
586 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200587}
588
589
Martin Polreich8663a342017-06-30 17:33:08 +0200590def installStacklight(master) {
591 def common = new com.mirantis.mk.Common()
592 def salt = new com.mirantis.mk.Salt()
593
Simon Pasquieref4122c2017-08-25 15:52:07 +0200594 // Install core services for K8S environments:
595 // HAProxy, Nginx and lusterFS clients
596 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200597 if (common.checkContains('STACK_INSTALL', 'k8s')) {
598 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
599 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200600
601 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100602 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200603 }
604
605 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100606 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200607 }
Martin Polreich792f2662017-07-11 13:36:32 +0200608 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200609
610 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100611 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
612 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200613
Martin Polreich8663a342017-06-30 17:33:08 +0200614 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100615 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200616
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400617 // Install Prometheus exporters
618 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100619 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400620 }
621
Martin Polreich8663a342017-06-30 17:33:08 +0200622 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100623 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
624 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
625 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
626 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
627 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
628 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
629 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
630 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Martin Polreich8663a342017-06-30 17:33:08 +0200631
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400632 // Install service for the log collection
633 if (salt.testTarget(master, 'I@fluentd:agent')) {
634 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
635 } else {
636 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
637 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200638
Ondrej Smola5908ae62018-01-08 13:42:08 +0100639 // Install heka ceilometer collector
640 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100641 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100642 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
643 }
644
Martin Polreich470925a2017-07-06 17:12:59 +0200645 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200646 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100647 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
648 salt.enforceState(master, 'I@galera:slave', 'galera')
Martin Polreich406f6462017-07-11 11:33:42 +0000649
Martin Polreich792f2662017-07-11 13:36:32 +0200650 // Check galera status
651 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
652 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
653 }
Martin Polreich470925a2017-07-06 17:12:59 +0200654
Martin Polreich8663a342017-06-30 17:33:08 +0200655 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100656 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
657 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
658 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200659 sleep(5)
660
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400661 // Configure Prometheus in Docker Swarm
662 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false)
663
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400664 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400665 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400666 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200667 }
Martin Polreich8663a342017-06-30 17:33:08 +0200668
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100669 // Install sphinx server
670 if (salt.testTarget(master, 'I@sphinx:server')) {
671 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
672 }
673
Martin Polreich8663a342017-06-30 17:33:08 +0200674 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200675 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200676 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200677
Martin Polreich8663a342017-06-30 17:33:08 +0200678 def stacklight_vip
679 if(!pillar['return'].isEmpty()) {
680 stacklight_vip = pillar['return'][0].values()[0]
681 } else {
682 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
683 }
vrovachev1c4770b2017-07-05 13:25:21 +0400684
Martin Polreich305e2222017-07-06 11:33:00 +0200685 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200686 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100687 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200688}
689
690def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200691 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200692
693 // infra install
694 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100695 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
696 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200697
Jakub Josef432e9d92018-02-06 18:28:37 +0100698 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
699 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200700
Jakub Josef432e9d92018-02-06 18:28:37 +0100701 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
702 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200703
Jakub Josef432e9d92018-02-06 18:28:37 +0100704 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
705 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200706
Kalynovskyi3e370112017-06-26 12:48:23 +0300707 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
708 def alarming_service = alarming_service_pillar['return'][0].values()[0]
709
710 switch (alarming_service) {
711 case 'sensu':
712 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100713 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
714 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
715 salt.enforceState(master, 'I@redis:server', 'redis')
716 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300717 default:
718 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100719 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300720 // Stop the Nagios service because the package starts it by default and it will
721 // started later only on the node holding the VIP address
722 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
723 }
724
Jakub Josef432e9d92018-02-06 18:28:37 +0100725 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
726 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200727
728 sleep(10)
729}
730
Martin Polreich8663a342017-06-30 17:33:08 +0200731def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200732 def salt = new com.mirantis.mk.Salt()
733 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200734
Jakub Josef432e9d92018-02-06 18:28:37 +0100735 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200736 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100737 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200738 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
739
740 // Install collectd, heka and sensu services on the nodes, this will also
741 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100742 salt.enforceState(master, '*', 'collectd')
743 salt.enforceState(master, '*', 'salt.minion')
744 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200745
746 // Gather the Grafana metadata as grains
747 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
748
749 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100750 salt.enforceState(master, '*', 'salt.minion.grains')
751 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
752 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200753
754 sleep(5)
755
756 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100757 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200758
759 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100760 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200761
Kalynovskyi3e370112017-06-26 12:48:23 +0300762 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
763 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200764
Kalynovskyi3e370112017-06-26 12:48:23 +0300765 switch (alarming_service) {
766 case 'sensu':
767 // Update Sensu
768 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100769 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300770 default:
771 break
772 // Default is nagios, and was enforced in installStacklightControl()
773 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200774
Jakub Josef432e9d92018-02-06 18:28:37 +0100775 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200776 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
777
Marek Celoudd200cad2017-06-07 10:34:46 +0200778 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100779 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
780 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
781 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200782 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
783
Ales Komarekef2bab62017-04-26 11:48:28 +0200784 // Get the StackLight monitoring VIP addres
785 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
786 //vip=${vip:=172.16.10.253}
787 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200788 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200789 def stacklight_vip = pillar['return'][0].values()[0]
790
791 if (stacklight_vip) {
792 // (re)Start manually the services that are bound to the monitoring VIP
793 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100794 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
795 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
796 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
797 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200798 } else {
799 throw new Exception("Missing stacklight_vip")
800 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100801}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200802
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100803//
804// backups
805//
806
807def installBackup(master, component='common') {
808 def salt = new com.mirantis.mk.Salt()
809 if (component == 'common') {
810 // Install Backupninja
811 if (salt.testTarget(master, 'I@backupninja:client')) {
812 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
813 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
814 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
815 salt.enforceState(master, 'I@backupninja:client', 'xtrabackup')
816 }
817 if (salt.testTarget(master, 'I@backupninja:server')) {
818 salt.enforceState(master, 'I@backupninja:server', 'xtrabackup')
819 }
820 } else if (component == 'mysql') {
821 // Install Xtrabackup
822 if (salt.testTarget(master, 'I@xtrabackup:client')) {
823 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
824 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
825 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
826 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
827 }
828 if (salt.testTarget(master, 'I@xtrabackup:server')) {
829 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
830 }
831 } else if (component == 'contrail') {
832
833 // Install Cassandra backup
834 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
835 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
836 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
837 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
838 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
839 }
840 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
841 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
842 }
843 // Install Zookeeper backup
844 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
845 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
846 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
847 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
848 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
849 }
850 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
851 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
852 }
853 } else if (component == 'ceph') {
854 // Install Ceph backup
855 if (salt.testTarget(master, 'I@ceph:backup:client')) {
856 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
857 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
858 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
859 salt.enforceState(master, 'I@ceph:backup:client', 'zookeeper.backup')
860 }
861 if (salt.testTarget(master, 'I@ceph:backup:server')) {
862 salt.enforceState(master, 'I@ceph:backup:server', 'zookeeper.backup')
863 }
864 }
865
866}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200867
868//
869// Ceph
870//
871
Tomáš Kukráled27a472017-08-29 10:26:25 +0200872def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200873 def salt = new com.mirantis.mk.Salt()
874
Jakub Josef432e9d92018-02-06 18:28:37 +0100875 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200876
Jiri Broulike57a0242017-10-06 13:38:47 +0200877 // generate keyrings
878 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100879 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
880 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
881 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200882 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200883 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200884 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100885 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200886 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100887 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200888 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200889}
890
Tomáš Kukráled27a472017-08-29 10:26:25 +0200891def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200892 def salt = new com.mirantis.mk.Salt()
893
894 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100895 salt.enforceState(master, target, 'ceph.osd')
896 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
897 salt.enforceState(master, target, 'ceph.osd.custom')
898 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
899 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100900 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200901
Jiri Broulike57a0242017-10-06 13:38:47 +0200902 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200903 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200904 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100905 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200906 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200907}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200908
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200909def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200910 def salt = new com.mirantis.mk.Salt()
911
912 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200913 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100914 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
915 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400916 }
917 // setup Keystone service and endpoints for swift or / and S3
918 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100919 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200920 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200921}
Jiri Broulike57a0242017-10-06 13:38:47 +0200922
923def connectCeph(master) {
924 def salt = new com.mirantis.mk.Salt()
925
926 // connect Ceph to the env
927 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100928 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200929 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
930 }
931 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100932 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200933 }
934 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100935 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
936 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
937 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200938 }
939}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400940
941def installOssInfra(master) {
942 def common = new com.mirantis.mk.Common()
943 def salt = new com.mirantis.mk.Salt()
944
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400945 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400946 def orchestrate = new com.mirantis.mk.Orchestrate()
947 orchestrate.installInfra(master)
948 }
949
950 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100951 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
952 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
953 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400954 }
955}
956
957def installOss(master) {
958 def common = new com.mirantis.mk.Common()
959 def salt = new com.mirantis.mk.Salt()
960
961 //Get oss VIP address
962 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
963 common.prettyPrint(pillar)
964
965 def oss_vip
966 if(!pillar['return'].isEmpty()) {
967 oss_vip = pillar['return'][0].values()[0]
968 } else {
969 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
970 }
971
972 // Postgres client - initialize OSS services databases
973 timeout(120){
974 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -0600975 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 +0400976 }
977 // XXX: first run usually fails on some inserts, but we need to create databases at first
978 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
979
980 // Setup postgres database with integration between
981 // Pushkin notification service and Security Monkey security audit service
982 timeout(10) {
983 common.infoMsg("Waiting for Pushkin to come up..")
984 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
985 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100986 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400987
988 // Rundeck
989 timeout(10) {
990 common.infoMsg("Waiting for Rundeck to come up..")
991 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
992 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100993 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400994
995 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +0400996 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
997 def elasticsearch_vip
998 if(!pillar['return'].isEmpty()) {
999 elasticsearch_vip = pillar['return'][0].values()[0]
1000 } else {
1001 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1002 }
1003
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001004 timeout(10) {
1005 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001006 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 +04001007 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001008 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001009}