blob: f2a0ae2ce43fd832161fb02e83b749f88526a581 [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)
Jakub Josef9994ea72018-03-05 13:23:07 +010095 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +040096
97 // Check galera status
98 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
99 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300100 // If galera is not enabled check if we need to install mysql:server
101 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100102 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300103 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100104 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300105 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200106 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100107 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200108
vrovachev1c4770b2017-07-05 13:25:21 +0400109 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200110 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400111 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200112 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400113 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200114
vrovachev1c4770b2017-07-05 13:25:21 +0400115 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200116 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100117 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
118 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400119 }
120
121 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200122 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100123 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400124
125 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100126 common.retry(3,5){
127 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
128 }
vrovachev1c4770b2017-07-05 13:25:21 +0400129 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200130
Jakub Josef79ecec32017-02-17 14:36:28 +0100131 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200132 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100133 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400134 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
135 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
136 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200137
Jakub Josef79ecec32017-02-17 14:36:28 +0100138 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200139 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100140 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400141 }
142
143 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200144 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400145 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100146 common.retry(3,5){
147 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
148 }
vrovachev1c4770b2017-07-05 13:25:21 +0400149 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200150
151 // Install redis
152 if (salt.testTarget(master, 'I@redis:server')) {
153 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
154 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
155 }
156 salt.enforceState(master, 'I@redis:server', 'redis')
157 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100158 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400159}
160
161def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100162 def common = new com.mirantis.mk.Common()
163 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
164 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100165}
166
167
Ales Komarekef2bab62017-04-26 11:48:28 +0200168def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100169 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100170 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200171
172 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300173 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100174 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300175 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100176 // Install sphinx server
177 if (salt.testTarget(master, 'I@sphinx:server')) {
178 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
179 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300180 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100181 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
182 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300183 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200184
Jakub Josef79ecec32017-02-17 14:36:28 +0100185 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300186 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100187 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
188 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300189 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100190
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300191 // keystone:client must be called locally
192 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
193 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
194 sleep(30)
195 }
196 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100197 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
198 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300199 }
200 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100201 common.retry(3,5){
202 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
203 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300204 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100205
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300206 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300207 if (salt.testTarget(master, 'I@glance:server')) {
208 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100209 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
210 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300211 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200212
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300213 // Check glance service
214 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100215 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200216 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100217 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300218 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200219
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400220 // Create glance resources
221 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100222 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400223 }
224
Jakub Josef79ecec32017-02-17 14:36:28 +0100225 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300226 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100227 // run on first node first
228 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
229 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300230 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100231 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200232 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100233 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300234 }
235 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200236
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400237 // Create nova resources
238 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100239 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400240 }
241
Jakub Josef79ecec32017-02-17 14:36:28 +0100242 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300243 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100244 // run on first node first
245 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
246 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300247 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100248 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200249 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100250 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300251 }
252 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200253
Jakub Josef79ecec32017-02-17 14:36:28 +0100254 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300255 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100256 // run on first node first
257 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
258 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300259 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100260 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200261 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100262 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300263 }
264 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200265
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400266 // Create neutron resources
267 if (salt.testTarget(master, 'I@neutron:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100268 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400269 }
270
Jakub Josef79ecec32017-02-17 14:36:28 +0100271 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300272 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100273 // run on first node first
274 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
275 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300276 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100277 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200278 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100279 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300280 }
281 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200282
283 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300284 if (salt.testTarget(master, 'I@nova:controller')) {
285 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
286 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300287
288 // Install ironic service
289 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100290 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
291 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300292 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300293
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200294 // Install manila service
295 if (salt.testTarget(master, 'I@manila:api')) {
296 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
297 salt.enforceState(master, 'I@manila:api', 'manila.api')
298 }
299 if (salt.testTarget(master, 'I@manila:scheduler')) {
300 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
301 }
302
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300303 // Install designate service
304 if (salt.testTarget(master, 'I@designate:server:enabled')) {
305 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100306 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300307 }
308 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100309 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300310 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100311 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
312 salt.enforceState(master, 'I@designate:server', 'designate.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300313 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400314
315 // Install octavia api service
316 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100317 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100318 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400319 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200320
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200321 // Install DogTag server service
322 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100323 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
324 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200325 }
326
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200327 // Install barbican server service
328 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100329 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
330 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200331 }
332 // Install barbican client
333 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100334 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200335 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100336
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200337 // Install gnocchi server
338 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200339 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200340 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
341 }
342
343 // Install gnocchi statsd
344 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200345 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200346 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
347 }
348
349 // Install panko server
350 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200351 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200352 salt.enforceState(master, 'I@panko:server', 'panko')
353 }
354
Ondrej Smola5908ae62018-01-08 13:42:08 +0100355 // Install ceilometer server
356 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200357 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100358 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100359 }
360
361 // Install aodh server
362 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200363 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100364 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100365 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100366}
367
368
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300369def installIronicConductor(master){
370 def salt = new com.mirantis.mk.Salt()
371
372 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100373 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
374 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300375 }
376 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100377 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300378 }
379
380 if (salt.testTarget(master, 'I@nova:compute')) {
381 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
382 }
383
384 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100385 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300386 }
387 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100388 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300389 }
390}
391
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200392def installManilaShare(master){
393 def salt = new com.mirantis.mk.Salt()
394
395 if (salt.testTarget(master, 'I@manila:share')) {
396 salt.enforceState(master, 'I@manila:share', 'manila.share')
397 }
398 if (salt.testTarget(master, 'I@manila:data')) {
399 salt.enforceState(master, 'I@manila:data', 'manila.data')
400 }
401
402 if (salt.testTarget(master, 'I@manila:client')) {
403 salt.enforceState(master, 'I@manila:client', 'manila.client')
404 }
405}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300406
407
Ales Komarekef2bab62017-04-26 11:48:28 +0200408def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100409 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200410
Jakub Josef432e9d92018-02-06 18:28:37 +0100411 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400412
413 // install octavia manager services
414 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100415 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
416 salt.enforceState(master, 'I@octavia:manager', 'octavia')
417 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
418 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400419 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200420}
421
422
423def installOpenstackCompute(master) {
424 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200425 // Configure compute nodes
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200426 if (salt.testTarget(master, 'I@nova:compute')) {
427 retry(2) {
428 salt.enforceHighstateWithExclude(master, 'I@nova:compute', 'opencontrail.client')
429 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200430 }
431}
432
433
434def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200435 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200436 def salt = new com.mirantis.mk.Salt()
437
438
Jakub Josef79ecec32017-02-17 14:36:28 +0100439 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100440 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
441 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200442
Jakub Josef79ecec32017-02-17 14:36:28 +0100443 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100444 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
445 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
446 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100447
Marek Celoud443fb642017-11-22 15:07:12 +0100448 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100449 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100450 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100451 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100452}
453
454
Ales Komarekef2bab62017-04-26 11:48:28 +0200455def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200456 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400457 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100458 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200459 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100460 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100461 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100462
vrovachev4ff77302017-08-09 20:39:57 +0400463 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200464 if (salt.testTarget(master, 'I@opencontrail:compute')) {
465 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
466 }
vrovachev4ff77302017-08-09 20:39:57 +0400467
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200468 if (salt.testTarget(master, 'I@nova:compute')) {
469 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)
470 }
vrovachev4ff77302017-08-09 20:39:57 +0400471
Jakub Josef61463c72018-02-13 16:10:56 +0100472 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400473 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100474 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
475 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400476 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100477}
478
479
Ales Komarekef2bab62017-04-26 11:48:28 +0200480def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100481 def common = new com.mirantis.mk.Common()
482 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
483 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100484}
485
486
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200487def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100488 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200489
Jakub Josef79ecec32017-02-17 14:36:28 +0100490 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200491 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
492 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100493
Marek Celoud029391c2017-11-14 10:06:18 +0100494 if (salt.testTarget(master, 'I@etcd:server:setup')) {
495 // Setup etcd server
496 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
497 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100498
499 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100500 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100501
502 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200503 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100504
505 // Restart kubelet
506 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
507}
508
509
Ales Komarekef2bab62017-04-26 11:48:28 +0200510def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200511 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100512 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200513
514 // Bootstrap all nodes
515 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
516 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
517 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
518
519 // Create and distribute SSL certificates for services using salt state
520 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
521
522 // Install docker
523 salt.enforceState(master, 'I@docker:host', 'docker.host')
524
525 // Install Kubernetes and Calico
526 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
527
Yuriy Taradayab564d72017-10-11 15:14:35 +0400528 // Install Tiller and all configured releases
529 if (salt.testTarget(master, 'I@helm:client')) {
530 salt.enforceState(master, 'I@helm:client', 'helm')
531 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200532}
533
534
Martin Polreich8663a342017-06-30 17:33:08 +0200535def installDockerSwarm(master) {
536 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100537
vrovachev1c4770b2017-07-05 13:25:21 +0400538 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200539 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100540 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
541 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
542 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
543 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200544 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100545 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
546 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100547 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100548 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200549}
550
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200551
552def installCicd(master) {
553 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100554 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100555
Richard Felklc1aba9b2018-01-02 09:25:20 +0100556 if (salt.testTarget(master, 'I@aptly:publisher')) {
557 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
558 }
559
Richard Felkl6de16762017-11-20 11:42:28 +0100560 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 +0200561 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100562
563 if (salt.testTarget(master, 'I@aptly:server')) {
564 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
565 }
566
567 if (salt.testTarget(master, 'I@openldap:client')) {
568 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
569 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200570
571 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100572 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200573 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100574
Richard Felkl6e208fc2017-12-08 10:18:44 +0100575 withEnv(['ASK_ON_ERROR=false']){
576 retry(2){
577 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100578 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100579 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100580 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100581 throw e //rethrow for retry handler
582 }
583 }
584 retry(2){
585 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100586 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100587 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100588 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100589 throw e //rethrow for retry handler
590 }
591 }
592 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200593}
594
595
Martin Polreich8663a342017-06-30 17:33:08 +0200596def installStacklight(master) {
597 def common = new com.mirantis.mk.Common()
598 def salt = new com.mirantis.mk.Salt()
599
Simon Pasquieref4122c2017-08-25 15:52:07 +0200600 // Install core services for K8S environments:
601 // HAProxy, Nginx and lusterFS clients
602 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200603 if (common.checkContains('STACK_INSTALL', 'k8s')) {
604 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
605 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200606
607 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100608 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200609 }
610
611 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100612 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200613 }
Martin Polreich792f2662017-07-11 13:36:32 +0200614 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200615
616 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100617 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
618 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200619
Martin Polreich8663a342017-06-30 17:33:08 +0200620 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100621 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200622
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400623 // Install Prometheus exporters
624 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100625 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400626 }
627
Martin Polreich8663a342017-06-30 17:33:08 +0200628 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100629 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
630 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
631 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
632 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
633 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
634 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
635 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
636 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Martin Polreich8663a342017-06-30 17:33:08 +0200637
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400638 // Install service for the log collection
639 if (salt.testTarget(master, 'I@fluentd:agent')) {
640 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
641 } else {
642 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
643 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200644
Ondrej Smola5908ae62018-01-08 13:42:08 +0100645 // Install heka ceilometer collector
646 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100647 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100648 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
649 }
650
Martin Polreich470925a2017-07-06 17:12:59 +0200651 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200652 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100653 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100654 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000655
Martin Polreich792f2662017-07-11 13:36:32 +0200656 // Check galera status
657 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
658 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
659 }
Martin Polreich470925a2017-07-06 17:12:59 +0200660
Martin Polreich8663a342017-06-30 17:33:08 +0200661 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100662 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
663 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
664 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200665 sleep(5)
666
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400667 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100668 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400669
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400670 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400671 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400672 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200673 }
Martin Polreich8663a342017-06-30 17:33:08 +0200674
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100675 // Install sphinx server
676 if (salt.testTarget(master, 'I@sphinx:server')) {
677 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
678 }
679
Martin Polreich8663a342017-06-30 17:33:08 +0200680 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200681 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200682 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200683
Martin Polreich8663a342017-06-30 17:33:08 +0200684 def stacklight_vip
685 if(!pillar['return'].isEmpty()) {
686 stacklight_vip = pillar['return'][0].values()[0]
687 } else {
688 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
689 }
vrovachev1c4770b2017-07-05 13:25:21 +0400690
Martin Polreich305e2222017-07-06 11:33:00 +0200691 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200692 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100693 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200694}
695
696def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200697 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200698
699 // infra install
700 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100701 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
702 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200703
Jakub Josef432e9d92018-02-06 18:28:37 +0100704 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
705 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200706
Jakub Josef432e9d92018-02-06 18:28:37 +0100707 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
708 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200709
Jakub Josef432e9d92018-02-06 18:28:37 +0100710 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
711 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200712
Kalynovskyi3e370112017-06-26 12:48:23 +0300713 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
714 def alarming_service = alarming_service_pillar['return'][0].values()[0]
715
716 switch (alarming_service) {
717 case 'sensu':
718 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100719 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
720 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
721 salt.enforceState(master, 'I@redis:server', 'redis')
722 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300723 default:
724 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100725 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300726 // Stop the Nagios service because the package starts it by default and it will
727 // started later only on the node holding the VIP address
728 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
729 }
730
Jakub Josef432e9d92018-02-06 18:28:37 +0100731 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
732 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200733
734 sleep(10)
735}
736
Martin Polreich8663a342017-06-30 17:33:08 +0200737def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200738 def salt = new com.mirantis.mk.Salt()
739 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200740
Jakub Josef432e9d92018-02-06 18:28:37 +0100741 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200742 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100743 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200744 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
745
746 // Install collectd, heka and sensu services on the nodes, this will also
747 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100748 salt.enforceState(master, '*', 'collectd')
749 salt.enforceState(master, '*', 'salt.minion')
750 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200751
752 // Gather the Grafana metadata as grains
753 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
754
755 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100756 salt.enforceState(master, '*', 'salt.minion.grains')
757 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
758 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200759
760 sleep(5)
761
762 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100763 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200764
765 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100766 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200767
Kalynovskyi3e370112017-06-26 12:48:23 +0300768 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
769 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200770
Kalynovskyi3e370112017-06-26 12:48:23 +0300771 switch (alarming_service) {
772 case 'sensu':
773 // Update Sensu
774 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100775 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300776 default:
777 break
778 // Default is nagios, and was enforced in installStacklightControl()
779 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200780
Jakub Josef432e9d92018-02-06 18:28:37 +0100781 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200782 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
783
Marek Celoudd200cad2017-06-07 10:34:46 +0200784 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100785 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
786 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
787 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200788 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
789
Ales Komarekef2bab62017-04-26 11:48:28 +0200790 // Get the StackLight monitoring VIP addres
791 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
792 //vip=${vip:=172.16.10.253}
793 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200794 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200795 def stacklight_vip = pillar['return'][0].values()[0]
796
797 if (stacklight_vip) {
798 // (re)Start manually the services that are bound to the monitoring VIP
799 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100800 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
801 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
802 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
803 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200804 } else {
805 throw new Exception("Missing stacklight_vip")
806 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100807}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200808
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100809//
810// backups
811//
812
813def installBackup(master, component='common') {
814 def salt = new com.mirantis.mk.Salt()
815 if (component == 'common') {
816 // Install Backupninja
817 if (salt.testTarget(master, 'I@backupninja:client')) {
818 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
819 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100820 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100821 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100822 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100823 }
824 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100825 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100826 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100827 }
828 } else if (component == 'mysql') {
829 // Install Xtrabackup
830 if (salt.testTarget(master, 'I@xtrabackup:client')) {
831 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
832 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100833 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100834 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
835 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
836 }
837 if (salt.testTarget(master, 'I@xtrabackup:server')) {
838 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
839 }
840 } else if (component == 'contrail') {
841
842 // Install Cassandra backup
843 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
844 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
845 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100846 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100847 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
848 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
849 }
850 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
851 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
852 }
853 // Install Zookeeper backup
854 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
855 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
856 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100857 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100858 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
859 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
860 }
861 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
862 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
863 }
864 } else if (component == 'ceph') {
865 // Install Ceph backup
866 if (salt.testTarget(master, 'I@ceph:backup:client')) {
867 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
868 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100869 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100870 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100871 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100872 }
873 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100874 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100875 }
876 }
877
878}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200879
880//
881// Ceph
882//
883
Tomáš Kukráled27a472017-08-29 10:26:25 +0200884def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200885 def salt = new com.mirantis.mk.Salt()
886
Jakub Josef432e9d92018-02-06 18:28:37 +0100887 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200888
Jiri Broulike57a0242017-10-06 13:38:47 +0200889 // generate keyrings
890 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100891 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
892 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
893 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200894 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200895 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200896 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100897 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200898 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100899 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200900 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200901}
902
Tomáš Kukráled27a472017-08-29 10:26:25 +0200903def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200904 def salt = new com.mirantis.mk.Salt()
905
906 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100907 salt.enforceState(master, target, 'ceph.osd')
908 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
909 salt.enforceState(master, target, 'ceph.osd.custom')
910 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
911 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100912 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200913
Jiri Broulike57a0242017-10-06 13:38:47 +0200914 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200915 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200916 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100917 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200918 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200919}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200920
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200921def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200922 def salt = new com.mirantis.mk.Salt()
923
924 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200925 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100926 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
927 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400928 }
929 // setup Keystone service and endpoints for swift or / and S3
930 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100931 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200932 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200933}
Jiri Broulike57a0242017-10-06 13:38:47 +0200934
935def connectCeph(master) {
936 def salt = new com.mirantis.mk.Salt()
937
938 // connect Ceph to the env
939 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100940 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200941 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
942 }
943 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100944 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200945 }
946 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100947 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
948 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
949 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200950 }
951}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400952
953def installOssInfra(master) {
954 def common = new com.mirantis.mk.Common()
955 def salt = new com.mirantis.mk.Salt()
956
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400957 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400958 def orchestrate = new com.mirantis.mk.Orchestrate()
959 orchestrate.installInfra(master)
960 }
961
962 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100963 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
964 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
965 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400966 }
967}
968
969def installOss(master) {
970 def common = new com.mirantis.mk.Common()
971 def salt = new com.mirantis.mk.Salt()
972
973 //Get oss VIP address
974 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
975 common.prettyPrint(pillar)
976
977 def oss_vip
978 if(!pillar['return'].isEmpty()) {
979 oss_vip = pillar['return'][0].values()[0]
980 } else {
981 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
982 }
983
984 // Postgres client - initialize OSS services databases
985 timeout(120){
986 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -0600987 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 +0400988 }
989 // XXX: first run usually fails on some inserts, but we need to create databases at first
990 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
991
992 // Setup postgres database with integration between
993 // Pushkin notification service and Security Monkey security audit service
994 timeout(10) {
995 common.infoMsg("Waiting for Pushkin to come up..")
996 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
997 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100998 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400999
1000 // Rundeck
1001 timeout(10) {
1002 common.infoMsg("Waiting for Rundeck to come up..")
1003 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1004 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001005 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001006
1007 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001008 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1009 def elasticsearch_vip
1010 if(!pillar['return'].isEmpty()) {
1011 elasticsearch_vip = pillar['return'][0].values()[0]
1012 } else {
1013 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1014 }
1015
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001016 timeout(10) {
1017 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001018 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 +04001019 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001020 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001021}