blob: 712fee6cee913fbe3dcd439fdcb2992978d96c56 [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)
vrovachevc4424a32018-03-15 17:35:57 +040040 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010041 salt.enforceState(master, '*', ['linux.network.host'])
Jakub Josef79ecec32017-02-17 14:36:28 +010042}
43
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010044def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020045 def salt = new com.mirantis.mk.Salt()
46
47 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010048 salt.fullRefresh(master, target)
49 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010050 if (staticMgmtNet) {
51 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
52 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020053 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010054 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020055
Jiri Broulike3e7bc32018-02-26 10:50:07 +010056 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020057 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040058 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010059 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020060}
61
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010062def installInfraKvm(master) {
63 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010064 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020065
Richard Felkl286f25f2017-07-26 14:23:55 +020066 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010067 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010068 salt.enforceState(master, 'I@salt:control', 'libvirt')
69 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010070
Ales Komarekef2bab62017-04-26 11:48:28 +020071 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010072
Jakub Josef432e9d92018-02-06 18:28:37 +010073 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010074}
Jakub Josef79ecec32017-02-17 14:36:28 +010075
vrovachev1c4770b2017-07-05 13:25:21 +040076def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010077 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010078 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020079
Jakub Josef79ecec32017-02-17 14:36:28 +010080 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020081 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010082 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010083
Jakub Josef432e9d92018-02-06 18:28:37 +010084 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +010085 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +010086 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +020087 }
Ales Komarekef2bab62017-04-26 11:48:28 +020088
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030089 // Ensure glusterfs clusters is ready
90 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010091 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030092 }
93
Jakub Josef79ecec32017-02-17 14:36:28 +010094 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +020095 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010096 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +010097 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +040098
99 // Check galera status
100 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
101 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300102 // If galera is not enabled check if we need to install mysql:server
103 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100104 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300105 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100106 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300107 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200108 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100109 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200110
vrovachev1c4770b2017-07-05 13:25:21 +0400111 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200112 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400113 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200114 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400115 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200116
vrovachev1c4770b2017-07-05 13:25:21 +0400117 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200118 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100119 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
120 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400121 }
122
123 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200124 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100125 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400126
127 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100128 common.retry(3,5){
129 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
130 }
vrovachev1c4770b2017-07-05 13:25:21 +0400131 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200132
Jakub Josef79ecec32017-02-17 14:36:28 +0100133 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200134 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100135 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400136 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
137 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
138 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200139
Jakub Josef79ecec32017-02-17 14:36:28 +0100140 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200141 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100142 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400143 }
144
145 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200146 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400147 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100148 common.retry(3,5){
149 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
150 }
vrovachev1c4770b2017-07-05 13:25:21 +0400151 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200152
153 // Install redis
154 if (salt.testTarget(master, 'I@redis:server')) {
155 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
156 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
157 }
158 salt.enforceState(master, 'I@redis:server', 'redis')
159 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100160 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400161}
162
163def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100164 def common = new com.mirantis.mk.Common()
165 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
166 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100167}
168
169
Ales Komarekef2bab62017-04-26 11:48:28 +0200170def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100171 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100172 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200173
174 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300175 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100176 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300177 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100178 // Install sphinx server
179 if (salt.testTarget(master, 'I@sphinx:server')) {
180 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
181 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300182 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100183 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
184 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300185 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200186
Jakub Josef79ecec32017-02-17 14:36:28 +0100187 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300188 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100189 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
190 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300191 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100192
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300193 // keystone:client must be called locally
194 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
195 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
196 sleep(30)
197 }
198 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100199 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
200 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300201 }
202 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100203 common.retry(3,5){
204 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
205 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100207
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300208 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300209 if (salt.testTarget(master, 'I@glance:server')) {
210 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100211 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
212 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300213 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200214
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300215 // Check glance service
216 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100217 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200218 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100219 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300220 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200221
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400222 // Create glance resources
223 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100224 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400225 }
226
Jakub Josef79ecec32017-02-17 14:36:28 +0100227 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300228 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100229 // run on first node first
230 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
231 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300232 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100233 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200234 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100235 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300236 }
237 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200238
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400239 // Create nova resources
240 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100241 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400242 }
243
Jakub Josef79ecec32017-02-17 14:36:28 +0100244 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300245 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100246 // run on first node first
247 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
248 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300249 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100250 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200251 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100252 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300253 }
254 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200255
Jakub Josef79ecec32017-02-17 14:36:28 +0100256 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300257 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100258 // run on first node first
259 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
260 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300261 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100262 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200263 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100264 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300265 }
266 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200267
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400268 // Create neutron resources
269 if (salt.testTarget(master, 'I@neutron:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100270 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400271 }
272
Jakub Josef79ecec32017-02-17 14:36:28 +0100273 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300274 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100275 // run on first node first
276 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
277 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300278 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100279 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200280 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100281 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300282 }
283 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200284
285 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300286 if (salt.testTarget(master, 'I@nova:controller')) {
287 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
288 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300289
290 // Install ironic service
291 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100292 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
293 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300294 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300295
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200296 // Install manila service
297 if (salt.testTarget(master, 'I@manila:api')) {
298 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
299 salt.enforceState(master, 'I@manila:api', 'manila.api')
300 }
301 if (salt.testTarget(master, 'I@manila:scheduler')) {
302 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
303 }
304
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200305 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300306 if (salt.testTarget(master, 'I@designate:server:enabled')) {
307 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100308 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300309 }
310 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100311 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300312 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100313 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200314 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300315 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400316
317 // Install octavia api service
318 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100319 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100320 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400321 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200322
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200323 // Install DogTag server service
324 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100325 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
326 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200327 }
328
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200329 // Install barbican server service
330 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100331 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
332 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200333 }
334 // Install barbican client
335 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100336 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200337 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100338
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200339 // Install gnocchi server
340 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200341 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200342 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
343 }
344
345 // Install gnocchi statsd
346 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200347 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200348 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
349 }
350
351 // Install panko server
352 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200353 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200354 salt.enforceState(master, 'I@panko:server', 'panko')
355 }
356
Ondrej Smola5908ae62018-01-08 13:42:08 +0100357 // Install ceilometer server
358 if (salt.testTarget(master, 'I@ceilometer:server')) {
Dzmitry Stremkouskibccc2162018-04-18 10:25:31 +0200359 common.retry(3,5){
360 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
361 salt.runSaltProcessStep(master, 'I@ceilometer:server and *01*', 'service.restart', ['apache2'])
362 sleep(30)
363 }
364 common.retry(3,5){
365 salt.enforceState(master, 'I@ceilometer:server and not *01*', 'ceilometer')
366 salt.runSaltProcessStep(master, 'I@ceilometer:server and not *01*', 'service.restart', ['apache2'])
367 sleep(30)
368 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100369 }
370
371 // Install aodh server
372 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200373 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100374 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100375 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100376}
377
378
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300379def installIronicConductor(master){
380 def salt = new com.mirantis.mk.Salt()
381
382 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100383 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
384 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300385 }
386 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100387 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300388 }
389
390 if (salt.testTarget(master, 'I@nova:compute')) {
391 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
392 }
393
394 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100395 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300396 }
397 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100398 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300399 }
400}
401
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200402def installManilaShare(master){
403 def salt = new com.mirantis.mk.Salt()
404
405 if (salt.testTarget(master, 'I@manila:share')) {
406 salt.enforceState(master, 'I@manila:share', 'manila.share')
407 }
408 if (salt.testTarget(master, 'I@manila:data')) {
409 salt.enforceState(master, 'I@manila:data', 'manila.data')
410 }
411
412 if (salt.testTarget(master, 'I@manila:client')) {
413 salt.enforceState(master, 'I@manila:client', 'manila.client')
414 }
415}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300416
417
Ales Komarekef2bab62017-04-26 11:48:28 +0200418def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100419 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200420
Jakub Josef432e9d92018-02-06 18:28:37 +0100421 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400422
423 // install octavia manager services
424 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100425 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
426 salt.enforceState(master, 'I@octavia:manager', 'octavia')
427 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
428 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400429 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200430}
431
432
433def installOpenstackCompute(master) {
434 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200435 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100436 def compute_compound = 'I@nova:compute'
437 if (salt.testTarget(master, compute_compound)) {
438 // In case if infrastructure nodes are used as nova computes too
439 def gluster_compound = 'I@glusterfs:server'
440 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200441 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100442 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
443 }
444 // Iterate through glusterfs servers and check if they have compute role
445 // TODO: switch to batch once salt 2017.7+ would be used
446 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
447 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
448 if ( target == cmp_target ) {
449 // Enforce highstate one by one on glusterfs servers which are compute nodes
450 retry(2) {
451 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
452 }
453 }
454 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200455 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200456 }
457}
458
459
460def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200461 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200462 def salt = new com.mirantis.mk.Salt()
463
464
Jakub Josef79ecec32017-02-17 14:36:28 +0100465 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100466 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
467 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200468
Jakub Josef79ecec32017-02-17 14:36:28 +0100469 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100470 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
471 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
472 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100473
Marek Celoud443fb642017-11-22 15:07:12 +0100474 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100475 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100476 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100477 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100478}
479
480
Ales Komarekef2bab62017-04-26 11:48:28 +0200481def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200482 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400483 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100484 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200485 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100486 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100487 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100488
vrovachev4ff77302017-08-09 20:39:57 +0400489 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200490 if (salt.testTarget(master, 'I@opencontrail:compute')) {
491 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
492 }
vrovachev4ff77302017-08-09 20:39:57 +0400493
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200494 if (salt.testTarget(master, 'I@nova:compute')) {
495 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)
496 }
vrovachev4ff77302017-08-09 20:39:57 +0400497
Jakub Josef61463c72018-02-13 16:10:56 +0100498 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400499 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100500 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
501 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400502 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100503}
504
505
Ales Komarekef2bab62017-04-26 11:48:28 +0200506def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100507 def common = new com.mirantis.mk.Common()
508 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
509 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100510}
511
512
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200513def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100514 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200515
Jakub Josef79ecec32017-02-17 14:36:28 +0100516 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200517 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
518 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100519
Marek Celoud029391c2017-11-14 10:06:18 +0100520 if (salt.testTarget(master, 'I@etcd:server:setup')) {
521 // Setup etcd server
522 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
523 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100524
525 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100526 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100527
528 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200529 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100530
531 // Restart kubelet
532 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
533}
534
535
Ales Komarekef2bab62017-04-26 11:48:28 +0200536def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200537 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100538 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200539
540 // Bootstrap all nodes
541 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
542 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
543 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
544
545 // Create and distribute SSL certificates for services using salt state
546 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
547
548 // Install docker
549 salt.enforceState(master, 'I@docker:host', 'docker.host')
550
551 // Install Kubernetes and Calico
552 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
553
Yuriy Taradayab564d72017-10-11 15:14:35 +0400554 // Install Tiller and all configured releases
555 if (salt.testTarget(master, 'I@helm:client')) {
556 salt.enforceState(master, 'I@helm:client', 'helm')
557 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200558}
559
560
Martin Polreich8663a342017-06-30 17:33:08 +0200561def installDockerSwarm(master) {
562 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100563
vrovachev1c4770b2017-07-05 13:25:21 +0400564 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200565 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100566 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
567 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
568 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
569 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200570 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100571 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
572 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100573 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100574 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200575}
576
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200577
578def installCicd(master) {
579 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100580 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100581
Richard Felklc1aba9b2018-01-02 09:25:20 +0100582 if (salt.testTarget(master, 'I@aptly:publisher')) {
583 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
584 }
585
Richard Felkl6de16762017-11-20 11:42:28 +0100586 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 +0200587 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100588
589 if (salt.testTarget(master, 'I@aptly:server')) {
590 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
591 }
592
593 if (salt.testTarget(master, 'I@openldap:client')) {
594 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
595 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200596
597 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100598 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200599 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100600
Richard Felkl6e208fc2017-12-08 10:18:44 +0100601 withEnv(['ASK_ON_ERROR=false']){
602 retry(2){
603 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100604 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100605 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100606 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100607 throw e //rethrow for retry handler
608 }
609 }
610 retry(2){
611 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100612 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100613 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100614 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100615 throw e //rethrow for retry handler
616 }
617 }
618 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200619}
620
621
Martin Polreich8663a342017-06-30 17:33:08 +0200622def installStacklight(master) {
623 def common = new com.mirantis.mk.Common()
624 def salt = new com.mirantis.mk.Salt()
625
Simon Pasquieref4122c2017-08-25 15:52:07 +0200626 // Install core services for K8S environments:
627 // HAProxy, Nginx and lusterFS clients
628 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200629 if (common.checkContains('STACK_INSTALL', 'k8s')) {
630 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
631 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200632
633 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100634 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200635 }
636
637 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100638 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200639 }
Martin Polreich792f2662017-07-11 13:36:32 +0200640 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200641
642 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100643 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
644 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200645
Martin Polreich8663a342017-06-30 17:33:08 +0200646 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100647 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200648
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400649 // Install Prometheus exporters
650 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100651 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400652 }
653
Martin Polreich8663a342017-06-30 17:33:08 +0200654 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100655 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
656 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
657 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
658 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
659 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
660 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400661
662 //Install InfluxDB
663 if (salt.testTarget(master, 'I@influxdb:server')) {
664 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
665 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
666 }
667
668 //Install Prometheus LTS
669 if (salt.testTarget(master, 'I@prometheus:relay')) {
670 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
671 }
Martin Polreich8663a342017-06-30 17:33:08 +0200672
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400673 // Install service for the log collection
674 if (salt.testTarget(master, 'I@fluentd:agent')) {
675 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
676 } else {
677 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
678 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200679
Ondrej Smola5908ae62018-01-08 13:42:08 +0100680 // Install heka ceilometer collector
681 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100682 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100683 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
684 }
685
Martin Polreich470925a2017-07-06 17:12:59 +0200686 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200687 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100688 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100689 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000690
Martin Polreich792f2662017-07-11 13:36:32 +0200691 // Check galera status
692 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
693 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
694 }
Martin Polreich470925a2017-07-06 17:12:59 +0200695
Martin Polreich8663a342017-06-30 17:33:08 +0200696 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100697 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
698 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
699 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200700 sleep(5)
701
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400702 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100703 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400704
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400705 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400706 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400707 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200708 }
Martin Polreich8663a342017-06-30 17:33:08 +0200709
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100710 // Install sphinx server
711 if (salt.testTarget(master, 'I@sphinx:server')) {
712 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
713 }
714
Martin Polreich8663a342017-06-30 17:33:08 +0200715 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200716 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200717 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200718
Martin Polreich8663a342017-06-30 17:33:08 +0200719 def stacklight_vip
720 if(!pillar['return'].isEmpty()) {
721 stacklight_vip = pillar['return'][0].values()[0]
722 } else {
723 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
724 }
vrovachev1c4770b2017-07-05 13:25:21 +0400725
Martin Polreich305e2222017-07-06 11:33:00 +0200726 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200727 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100728 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200729}
730
731def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200732 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200733
734 // infra install
735 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100736 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
737 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200738
Jakub Josef432e9d92018-02-06 18:28:37 +0100739 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
740 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200741
Jakub Josef432e9d92018-02-06 18:28:37 +0100742 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
743 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200744
Jakub Josef432e9d92018-02-06 18:28:37 +0100745 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
746 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200747
Kalynovskyi3e370112017-06-26 12:48:23 +0300748 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
749 def alarming_service = alarming_service_pillar['return'][0].values()[0]
750
751 switch (alarming_service) {
752 case 'sensu':
753 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100754 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
755 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
756 salt.enforceState(master, 'I@redis:server', 'redis')
757 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300758 default:
759 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100760 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300761 // Stop the Nagios service because the package starts it by default and it will
762 // started later only on the node holding the VIP address
763 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
764 }
765
Jakub Josef432e9d92018-02-06 18:28:37 +0100766 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
767 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200768
769 sleep(10)
770}
771
Martin Polreich8663a342017-06-30 17:33:08 +0200772def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200773 def salt = new com.mirantis.mk.Salt()
774 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200775
Jakub Josef432e9d92018-02-06 18:28:37 +0100776 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200777 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100778 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200779 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
780
781 // Install collectd, heka and sensu services on the nodes, this will also
782 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100783 salt.enforceState(master, '*', 'collectd')
784 salt.enforceState(master, '*', 'salt.minion')
785 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200786
787 // Gather the Grafana metadata as grains
788 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
789
790 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100791 salt.enforceState(master, '*', 'salt.minion.grains')
792 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
793 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200794
795 sleep(5)
796
797 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100798 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200799
800 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100801 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200802
Kalynovskyi3e370112017-06-26 12:48:23 +0300803 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
804 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200805
Kalynovskyi3e370112017-06-26 12:48:23 +0300806 switch (alarming_service) {
807 case 'sensu':
808 // Update Sensu
809 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100810 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300811 default:
812 break
813 // Default is nagios, and was enforced in installStacklightControl()
814 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200815
Jakub Josef432e9d92018-02-06 18:28:37 +0100816 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200817 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
818
Marek Celoudd200cad2017-06-07 10:34:46 +0200819 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100820 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
821 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
822 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200823 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
824
Ales Komarekef2bab62017-04-26 11:48:28 +0200825 // Get the StackLight monitoring VIP addres
826 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
827 //vip=${vip:=172.16.10.253}
828 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200829 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200830 def stacklight_vip = pillar['return'][0].values()[0]
831
832 if (stacklight_vip) {
833 // (re)Start manually the services that are bound to the monitoring VIP
834 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100835 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
836 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
837 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
838 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200839 } else {
840 throw new Exception("Missing stacklight_vip")
841 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100842}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200843
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100844//
845// backups
846//
847
848def installBackup(master, component='common') {
849 def salt = new com.mirantis.mk.Salt()
850 if (component == 'common') {
851 // Install Backupninja
852 if (salt.testTarget(master, 'I@backupninja:client')) {
853 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
854 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100855 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100856 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100857 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100858 }
859 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100860 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100861 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100862 }
863 } else if (component == 'mysql') {
864 // Install Xtrabackup
865 if (salt.testTarget(master, 'I@xtrabackup:client')) {
866 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
867 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100868 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100869 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
870 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
871 }
872 if (salt.testTarget(master, 'I@xtrabackup:server')) {
873 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
874 }
875 } else if (component == 'contrail') {
876
877 // Install Cassandra backup
878 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
879 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
880 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100881 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100882 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
883 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
884 }
885 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
886 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
887 }
888 // Install Zookeeper backup
889 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
890 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
891 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100892 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100893 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
894 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
895 }
896 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
897 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
898 }
899 } else if (component == 'ceph') {
900 // Install Ceph backup
901 if (salt.testTarget(master, 'I@ceph:backup:client')) {
902 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
903 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100904 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100905 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100906 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100907 }
908 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100909 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100910 }
911 }
912
913}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200914
915//
916// Ceph
917//
918
Tomáš Kukráled27a472017-08-29 10:26:25 +0200919def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200920 def salt = new com.mirantis.mk.Salt()
921
Jakub Josef432e9d92018-02-06 18:28:37 +0100922 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200923
Jiri Broulike57a0242017-10-06 13:38:47 +0200924 // generate keyrings
925 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100926 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
927 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
928 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200929 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200930 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200931 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100932 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200933 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100934 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200935 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200936}
937
Tomáš Kukráled27a472017-08-29 10:26:25 +0200938def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200939 def salt = new com.mirantis.mk.Salt()
940
941 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100942 salt.enforceState(master, target, 'ceph.osd')
943 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
944 salt.enforceState(master, target, 'ceph.osd.custom')
945 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
946 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100947 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200948
Jiri Broulike57a0242017-10-06 13:38:47 +0200949 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200950 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200951 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100952 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200953 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200954}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200955
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200956def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200957 def salt = new com.mirantis.mk.Salt()
958
959 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200960 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100961 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
962 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400963 }
964 // setup Keystone service and endpoints for swift or / and S3
965 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100966 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200967 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200968}
Jiri Broulike57a0242017-10-06 13:38:47 +0200969
970def connectCeph(master) {
971 def salt = new com.mirantis.mk.Salt()
972
973 // connect Ceph to the env
974 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100975 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200976 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
977 }
978 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100979 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200980 }
981 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100982 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
983 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
984 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200985 }
986}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400987
988def installOssInfra(master) {
989 def common = new com.mirantis.mk.Common()
990 def salt = new com.mirantis.mk.Salt()
991
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400992 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400993 def orchestrate = new com.mirantis.mk.Orchestrate()
994 orchestrate.installInfra(master)
995 }
996
997 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100998 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
999 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1000 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001001 }
1002}
1003
1004def installOss(master) {
1005 def common = new com.mirantis.mk.Common()
1006 def salt = new com.mirantis.mk.Salt()
1007
1008 //Get oss VIP address
1009 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1010 common.prettyPrint(pillar)
1011
1012 def oss_vip
1013 if(!pillar['return'].isEmpty()) {
1014 oss_vip = pillar['return'][0].values()[0]
1015 } else {
1016 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1017 }
1018
1019 // Postgres client - initialize OSS services databases
1020 timeout(120){
1021 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001022 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 +04001023 }
1024 // XXX: first run usually fails on some inserts, but we need to create databases at first
1025 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1026
1027 // Setup postgres database with integration between
1028 // Pushkin notification service and Security Monkey security audit service
1029 timeout(10) {
1030 common.infoMsg("Waiting for Pushkin to come up..")
1031 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1032 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001033 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001034
1035 // Rundeck
1036 timeout(10) {
1037 common.infoMsg("Waiting for Rundeck to come up..")
1038 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1039 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001040 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001041
1042 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001043 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1044 def elasticsearch_vip
1045 if(!pillar['return'].isEmpty()) {
1046 elasticsearch_vip = pillar['return'][0].values()[0]
1047 } else {
1048 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1049 }
1050
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001051 timeout(10) {
1052 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001053 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 +04001054 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001055 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001056}