blob: de55a420bced87c8a509a9ba22e585cfec2a60ea [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()
Jiri Broulik037f8982018-04-23 17:07:16 +020019 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +020020
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020021 // NOTE(vsaienko) Apply reclass first, it may update cluster model
22 // apply linux and salt.master salt.minion states afterwards to make sure
23 // correct cluster model is used.
Jakub Josef432e9d92018-02-06 18:28:37 +010024 salt.enforceState(master, 'I@salt:master', ['reclass'])
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020025
Jakub Josef432e9d92018-02-06 18:28:37 +010026 salt.enforceState(master, 'I@salt:master', ['linux.system'])
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020027 salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010028 salt.fullRefresh(master, "*")
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020029
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030030 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010031 salt.enforceState(master, 'I@salt:master', ['salt.minion'])
32 salt.fullRefresh(master, "*")
Ondrej Smolaa9b84662018-04-18 11:22:19 +020033 salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020034 try {
35 salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2)
36 sleep(5)
37 } catch (Throwable e) {
38 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
39 }
Jakub Josef432e9d92018-02-06 18:28:37 +010040 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010041 if (staticMgmtNet) {
42 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
43 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +010044 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020045 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020046 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040047 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010048 salt.enforceState(master, '*', ['linux.network.host'])
Jakub Josef79ecec32017-02-17 14:36:28 +010049}
50
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010051def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020052 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020053 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020054
55 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010056 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020057 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020058 try {
59 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
60 sleep(5)
61 } catch (Throwable e) {
62 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
63 }
Jakub Josef432e9d92018-02-06 18:28:37 +010064 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010065 if (staticMgmtNet) {
66 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
67 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020068 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010069 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020070
Jiri Broulike3e7bc32018-02-26 10:50:07 +010071 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020072 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040073 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010074 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020075}
76
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010077def installInfraKvm(master) {
78 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010079 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020080
Richard Felkl286f25f2017-07-26 14:23:55 +020081 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010082 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010083 salt.enforceState(master, 'I@salt:control', 'libvirt')
84 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010085
Ales Komarekef2bab62017-04-26 11:48:28 +020086 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010087
Jakub Josef432e9d92018-02-06 18:28:37 +010088 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010089}
Jakub Josef79ecec32017-02-17 14:36:28 +010090
vrovachev1c4770b2017-07-05 13:25:21 +040091def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010092 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010093 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020094
Jakub Josef79ecec32017-02-17 14:36:28 +010095 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020096 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010097 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010098
Jakub Josef432e9d92018-02-06 18:28:37 +010099 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100100 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100101 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200102 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200103
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300104 // Ensure glusterfs clusters is ready
105 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100106 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300107 }
108
Jakub Josef79ecec32017-02-17 14:36:28 +0100109 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200110 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100111 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100112 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400113
114 // Check galera status
115 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
116 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300117 // If galera is not enabled check if we need to install mysql:server
118 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100119 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300120 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100121 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300122 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200123 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100124 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200125
vrovachev1c4770b2017-07-05 13:25:21 +0400126 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200127 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400128 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200129 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400130 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200131
vrovachev1c4770b2017-07-05 13:25:21 +0400132 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200133 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100134 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
135 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400136 }
137
138 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200139 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100140 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400141
142 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100143 common.retry(3,5){
144 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
145 }
vrovachev1c4770b2017-07-05 13:25:21 +0400146 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200147
Jakub Josef79ecec32017-02-17 14:36:28 +0100148 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200149 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100150 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400151 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
152 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
153 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200154
Jakub Josef79ecec32017-02-17 14:36:28 +0100155 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200156 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100157 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400158 }
159
160 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200161 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400162 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100163 common.retry(3,5){
164 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
165 }
vrovachev1c4770b2017-07-05 13:25:21 +0400166 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200167
168 // Install redis
169 if (salt.testTarget(master, 'I@redis:server')) {
170 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
171 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
172 }
173 salt.enforceState(master, 'I@redis:server', 'redis')
174 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100175 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400176}
177
178def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100179 def common = new com.mirantis.mk.Common()
180 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
181 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100182}
183
184
Ales Komarekef2bab62017-04-26 11:48:28 +0200185def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100186 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100187 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200188
189 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300190 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100191 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300192 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100193 // Install sphinx server
194 if (salt.testTarget(master, 'I@sphinx:server')) {
195 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
196 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300197 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100198 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
199 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300200 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200201
Jakub Josef79ecec32017-02-17 14:36:28 +0100202 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300203 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100204 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
205 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100207
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300208 // keystone:client must be called locally
209 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
210 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
211 sleep(30)
212 }
213 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100214 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
215 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300216 }
217 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100218 common.retry(3,5){
219 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
220 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300221 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100222
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300223 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300224 if (salt.testTarget(master, 'I@glance:server')) {
225 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100226 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
227 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300228 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200229
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300230 // Check glance service
231 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100232 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200233 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100234 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300235 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200236
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400237 // Create glance resources
238 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100239 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400240 }
241
Jakub Josef79ecec32017-02-17 14:36:28 +0100242 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300243 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100244 // run on first node first
245 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
246 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
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; nova service-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
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400254 // Create nova resources
255 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100256 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400257 }
258
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300260 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100261 // run on first node first
262 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
263 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300264 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100265 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200266 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100267 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300268 }
269 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200270
Jakub Josef79ecec32017-02-17 14:36:28 +0100271 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300272 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100273 // run on first node first
274 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
275 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
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; neutron agent-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
Jakub Josef79ecec32017-02-17 14:36:28 +0100283 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300284 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100285 // run on first node first
286 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
287 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300288 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100289 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200290 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100291 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300292 }
293 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200294
295 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300296 if (salt.testTarget(master, 'I@nova:controller')) {
297 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
298 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300299
300 // Install ironic service
301 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100302 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
303 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300304 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300305
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200306 // Install manila service
307 if (salt.testTarget(master, 'I@manila:api')) {
308 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
309 salt.enforceState(master, 'I@manila:api', 'manila.api')
310 }
311 if (salt.testTarget(master, 'I@manila:scheduler')) {
312 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
313 }
314
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200315 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300316 if (salt.testTarget(master, 'I@designate:server:enabled')) {
317 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100318 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300319 }
320 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100321 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300322 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100323 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200324 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300325 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400326
327 // Install octavia api service
328 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100329 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100330 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400331 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200332
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200333 // Install DogTag server service
334 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100335 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
336 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200337 }
338
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200339 // Install barbican server service
340 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100341 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
342 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200343 }
344 // Install barbican client
345 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100346 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200347 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100348
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200349 // Install gnocchi server
350 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200351 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200352 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
353 }
354
355 // Install gnocchi statsd
356 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200357 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200358 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
359 }
360
361 // Install panko server
362 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200363 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200364 salt.enforceState(master, 'I@panko:server', 'panko')
365 }
366
Ondrej Smola5908ae62018-01-08 13:42:08 +0100367 // Install ceilometer server
368 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200369 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100370 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100371 }
372
373 // Install aodh server
374 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200375 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100376 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100377 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100378}
379
380
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300381def installIronicConductor(master){
382 def salt = new com.mirantis.mk.Salt()
383
384 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100385 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
386 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300387 }
388 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100389 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300390 }
391
392 if (salt.testTarget(master, 'I@nova:compute')) {
393 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
394 }
395
396 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100397 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300398 }
399 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100400 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300401 }
402}
403
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200404def installManilaShare(master){
405 def salt = new com.mirantis.mk.Salt()
406
407 if (salt.testTarget(master, 'I@manila:share')) {
408 salt.enforceState(master, 'I@manila:share', 'manila.share')
409 }
410 if (salt.testTarget(master, 'I@manila:data')) {
411 salt.enforceState(master, 'I@manila:data', 'manila.data')
412 }
413
414 if (salt.testTarget(master, 'I@manila:client')) {
415 salt.enforceState(master, 'I@manila:client', 'manila.client')
416 }
417}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300418
419
Ales Komarekef2bab62017-04-26 11:48:28 +0200420def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100421 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300422 //run full neutron state on neutron.gateway - this will install
423 //neutron agents in addition to neutron server. Once neutron agents
424 //are up neutron resources can be created without hitting the situation when neutron resources are created
425 //prior to neutron agents which results in creating ports in non-usable state
426 if (salt.testTarget(master, 'I@neutron:gateway')) {
427 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
428 }
429
430 // Create neutron resources - this step was moved here to ensure that
431 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
432 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
433 if (salt.testTarget(master, 'I@neutron:client')) {
434 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
435 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200436
Jakub Josef432e9d92018-02-06 18:28:37 +0100437 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400438
439 // install octavia manager services
440 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100441 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
442 salt.enforceState(master, 'I@octavia:manager', 'octavia')
443 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
444 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400445 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200446}
447
448
449def installOpenstackCompute(master) {
450 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200451 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100452 def compute_compound = 'I@nova:compute'
453 if (salt.testTarget(master, compute_compound)) {
454 // In case if infrastructure nodes are used as nova computes too
455 def gluster_compound = 'I@glusterfs:server'
456 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200457 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100458 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
459 }
460 // Iterate through glusterfs servers and check if they have compute role
461 // TODO: switch to batch once salt 2017.7+ would be used
462 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
463 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
464 if ( target == cmp_target ) {
465 // Enforce highstate one by one on glusterfs servers which are compute nodes
466 retry(2) {
467 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
468 }
469 }
470 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200471 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200472 }
473}
474
475
476def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200477 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200478 def salt = new com.mirantis.mk.Salt()
479
480
Jakub Josef79ecec32017-02-17 14:36:28 +0100481 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100482 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
483 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200484
Jakub Josef79ecec32017-02-17 14:36:28 +0100485 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100486 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
487 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
488 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100489
Marek Celoud443fb642017-11-22 15:07:12 +0100490 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100491 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100492 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100493 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100494}
495
496
Ales Komarekef2bab62017-04-26 11:48:28 +0200497def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200498 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400499 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100500 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200501 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100502 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100503 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100504
vrovachev4ff77302017-08-09 20:39:57 +0400505 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200506 if (salt.testTarget(master, 'I@opencontrail:compute')) {
507 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
508 }
vrovachev4ff77302017-08-09 20:39:57 +0400509
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200510 if (salt.testTarget(master, 'I@nova:compute')) {
511 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)
512 }
vrovachev4ff77302017-08-09 20:39:57 +0400513
Jakub Josef61463c72018-02-13 16:10:56 +0100514 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400515 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100516 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
517 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400518 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100519}
520
521
Ales Komarekef2bab62017-04-26 11:48:28 +0200522def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100523 def common = new com.mirantis.mk.Common()
524 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
525 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100526}
527
528
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200529def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100530 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200531
Jakub Josef79ecec32017-02-17 14:36:28 +0100532 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200533 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
534 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100535
Marek Celoud029391c2017-11-14 10:06:18 +0100536 if (salt.testTarget(master, 'I@etcd:server:setup')) {
537 // Setup etcd server
538 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
539 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100540
541 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100542 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100543
544 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200545 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100546
547 // Restart kubelet
548 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
549}
550
551
Ales Komarekef2bab62017-04-26 11:48:28 +0200552def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200553 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100554 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200555
556 // Bootstrap all nodes
557 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
558 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
559 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
560
561 // Create and distribute SSL certificates for services using salt state
562 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
563
564 // Install docker
565 salt.enforceState(master, 'I@docker:host', 'docker.host')
566
567 // Install Kubernetes and Calico
568 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
569
Yuriy Taradayab564d72017-10-11 15:14:35 +0400570 // Install Tiller and all configured releases
571 if (salt.testTarget(master, 'I@helm:client')) {
572 salt.enforceState(master, 'I@helm:client', 'helm')
573 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200574}
575
576
Martin Polreich8663a342017-06-30 17:33:08 +0200577def installDockerSwarm(master) {
578 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100579
vrovachev1c4770b2017-07-05 13:25:21 +0400580 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200581 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100582 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
583 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
584 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
585 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200586 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100587 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
588 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100589 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100590 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200591}
592
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200593
594def installCicd(master) {
595 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100596 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100597
Richard Felklc1aba9b2018-01-02 09:25:20 +0100598 if (salt.testTarget(master, 'I@aptly:publisher')) {
599 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
600 }
601
Richard Felkl6de16762017-11-20 11:42:28 +0100602 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 +0200603 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100604
605 if (salt.testTarget(master, 'I@aptly:server')) {
606 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
607 }
608
609 if (salt.testTarget(master, 'I@openldap:client')) {
610 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
611 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200612
613 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100614 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200615 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100616
Richard Felkl6e208fc2017-12-08 10:18:44 +0100617 withEnv(['ASK_ON_ERROR=false']){
618 retry(2){
619 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100621 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100622 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100623 throw e //rethrow for retry handler
624 }
625 }
626 retry(2){
627 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100628 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100629 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100630 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100631 throw e //rethrow for retry handler
632 }
633 }
634 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200635}
636
637
Martin Polreich8663a342017-06-30 17:33:08 +0200638def installStacklight(master) {
639 def common = new com.mirantis.mk.Common()
640 def salt = new com.mirantis.mk.Salt()
641
Simon Pasquieref4122c2017-08-25 15:52:07 +0200642 // Install core services for K8S environments:
643 // HAProxy, Nginx and lusterFS clients
644 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200645 if (common.checkContains('STACK_INSTALL', 'k8s')) {
646 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
647 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200648
649 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100650 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200651 }
652
653 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100654 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200655 }
Martin Polreich792f2662017-07-11 13:36:32 +0200656 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200657
658 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100659 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
660 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200661
Martin Polreich8663a342017-06-30 17:33:08 +0200662 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100663 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200664
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400665 // Install Prometheus exporters
666 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100667 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400668 }
669
Martin Polreich8663a342017-06-30 17:33:08 +0200670 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100671 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
672 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
673 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
674 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
675 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
676 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400677
678 //Install InfluxDB
679 if (salt.testTarget(master, 'I@influxdb:server')) {
680 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
681 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
682 }
683
684 //Install Prometheus LTS
685 if (salt.testTarget(master, 'I@prometheus:relay')) {
686 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
687 }
Martin Polreich8663a342017-06-30 17:33:08 +0200688
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400689 // Install service for the log collection
690 if (salt.testTarget(master, 'I@fluentd:agent')) {
691 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
692 } else {
693 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
694 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200695
Ondrej Smola5908ae62018-01-08 13:42:08 +0100696 // Install heka ceilometer collector
697 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100698 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100699 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
700 }
701
Martin Polreich470925a2017-07-06 17:12:59 +0200702 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200703 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100704 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100705 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000706
Martin Polreich792f2662017-07-11 13:36:32 +0200707 // Check galera status
708 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
709 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
710 }
Martin Polreich470925a2017-07-06 17:12:59 +0200711
Martin Polreich8663a342017-06-30 17:33:08 +0200712 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100713 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
714 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
715 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200716 sleep(5)
717
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400718 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100719 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400720
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400721 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400722 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400723 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200724 }
Martin Polreich8663a342017-06-30 17:33:08 +0200725
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100726 // Install sphinx server
727 if (salt.testTarget(master, 'I@sphinx:server')) {
728 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
729 }
730
Martin Polreich8663a342017-06-30 17:33:08 +0200731 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200732 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200733 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200734
Martin Polreich8663a342017-06-30 17:33:08 +0200735 def stacklight_vip
736 if(!pillar['return'].isEmpty()) {
737 stacklight_vip = pillar['return'][0].values()[0]
738 } else {
739 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
740 }
vrovachev1c4770b2017-07-05 13:25:21 +0400741
Martin Polreich305e2222017-07-06 11:33:00 +0200742 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200743 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100744 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200745}
746
747def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200748 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200749
750 // infra install
751 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100752 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
753 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200754
Jakub Josef432e9d92018-02-06 18:28:37 +0100755 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
756 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200757
Jakub Josef432e9d92018-02-06 18:28:37 +0100758 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
759 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200760
Jakub Josef432e9d92018-02-06 18:28:37 +0100761 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
762 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200763
Kalynovskyi3e370112017-06-26 12:48:23 +0300764 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
765 def alarming_service = alarming_service_pillar['return'][0].values()[0]
766
767 switch (alarming_service) {
768 case 'sensu':
769 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100770 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
771 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
772 salt.enforceState(master, 'I@redis:server', 'redis')
773 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300774 default:
775 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100776 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300777 // Stop the Nagios service because the package starts it by default and it will
778 // started later only on the node holding the VIP address
779 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
780 }
781
Jakub Josef432e9d92018-02-06 18:28:37 +0100782 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
783 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200784
785 sleep(10)
786}
787
Martin Polreich8663a342017-06-30 17:33:08 +0200788def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200789 def salt = new com.mirantis.mk.Salt()
790 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200791
Jakub Josef432e9d92018-02-06 18:28:37 +0100792 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200793 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100794 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200795 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
796
797 // Install collectd, heka and sensu services on the nodes, this will also
798 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100799 salt.enforceState(master, '*', 'collectd')
800 salt.enforceState(master, '*', 'salt.minion')
801 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200802
803 // Gather the Grafana metadata as grains
804 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
805
806 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100807 salt.enforceState(master, '*', 'salt.minion.grains')
808 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
809 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200810
811 sleep(5)
812
813 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100814 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200815
816 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100817 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200818
Kalynovskyi3e370112017-06-26 12:48:23 +0300819 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
820 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200821
Kalynovskyi3e370112017-06-26 12:48:23 +0300822 switch (alarming_service) {
823 case 'sensu':
824 // Update Sensu
825 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100826 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300827 default:
828 break
829 // Default is nagios, and was enforced in installStacklightControl()
830 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200831
Jakub Josef432e9d92018-02-06 18:28:37 +0100832 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200833 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
834
Marek Celoudd200cad2017-06-07 10:34:46 +0200835 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100836 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
837 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
838 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200839 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
840
Ales Komarekef2bab62017-04-26 11:48:28 +0200841 // Get the StackLight monitoring VIP addres
842 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
843 //vip=${vip:=172.16.10.253}
844 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200845 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200846 def stacklight_vip = pillar['return'][0].values()[0]
847
848 if (stacklight_vip) {
849 // (re)Start manually the services that are bound to the monitoring VIP
850 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100851 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
852 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
853 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
854 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200855 } else {
856 throw new Exception("Missing stacklight_vip")
857 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100858}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200859
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100860//
861// backups
862//
863
864def installBackup(master, component='common') {
865 def salt = new com.mirantis.mk.Salt()
866 if (component == 'common') {
867 // Install Backupninja
868 if (salt.testTarget(master, 'I@backupninja:client')) {
869 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
870 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100871 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100872 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100873 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100874 }
875 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100876 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100877 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100878 }
879 } else if (component == 'mysql') {
880 // Install Xtrabackup
881 if (salt.testTarget(master, 'I@xtrabackup:client')) {
882 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
883 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100884 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100885 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
886 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
887 }
888 if (salt.testTarget(master, 'I@xtrabackup:server')) {
889 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
890 }
891 } else if (component == 'contrail') {
892
893 // Install Cassandra backup
894 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
895 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
896 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100897 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100898 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
899 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
900 }
901 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
902 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
903 }
904 // Install Zookeeper backup
905 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
906 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
907 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100908 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100909 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
910 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
911 }
912 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
913 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
914 }
915 } else if (component == 'ceph') {
916 // Install Ceph backup
917 if (salt.testTarget(master, 'I@ceph:backup:client')) {
918 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
919 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100920 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100921 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100922 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100923 }
924 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100925 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100926 }
927 }
928
929}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200930
931//
932// Ceph
933//
934
Tomáš Kukráled27a472017-08-29 10:26:25 +0200935def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200936 def salt = new com.mirantis.mk.Salt()
937
Jakub Josef432e9d92018-02-06 18:28:37 +0100938 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200939
Jiri Broulike57a0242017-10-06 13:38:47 +0200940 // generate keyrings
941 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100942 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
943 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
944 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200945 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200946 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200947 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100948 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200949 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100950 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200951 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200952}
953
Tomáš Kukráled27a472017-08-29 10:26:25 +0200954def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200955 def salt = new com.mirantis.mk.Salt()
956
957 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100958 salt.enforceState(master, target, 'ceph.osd')
959 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
960 salt.enforceState(master, target, 'ceph.osd.custom')
961 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
962 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100963 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200964
Jiri Broulike57a0242017-10-06 13:38:47 +0200965 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200966 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200967 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100968 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200969 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200970}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200971
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200972def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200973 def salt = new com.mirantis.mk.Salt()
974
975 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200976 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100977 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
978 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400979 }
980 // setup Keystone service and endpoints for swift or / and S3
981 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100982 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200983 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200984}
Jiri Broulike57a0242017-10-06 13:38:47 +0200985
986def connectCeph(master) {
987 def salt = new com.mirantis.mk.Salt()
988
989 // connect Ceph to the env
990 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100991 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200992 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
993 }
994 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100995 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200996 }
997 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100998 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
999 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1000 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001001 }
1002}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001003
1004def installOssInfra(master) {
1005 def common = new com.mirantis.mk.Common()
1006 def salt = new com.mirantis.mk.Salt()
1007
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001008 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001009 def orchestrate = new com.mirantis.mk.Orchestrate()
1010 orchestrate.installInfra(master)
1011 }
1012
1013 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001014 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1015 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1016 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001017 }
1018}
1019
1020def installOss(master) {
1021 def common = new com.mirantis.mk.Common()
1022 def salt = new com.mirantis.mk.Salt()
1023
1024 //Get oss VIP address
1025 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1026 common.prettyPrint(pillar)
1027
1028 def oss_vip
1029 if(!pillar['return'].isEmpty()) {
1030 oss_vip = pillar['return'][0].values()[0]
1031 } else {
1032 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1033 }
1034
1035 // Postgres client - initialize OSS services databases
1036 timeout(120){
1037 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001038 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 +04001039 }
1040 // XXX: first run usually fails on some inserts, but we need to create databases at first
1041 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1042
1043 // Setup postgres database with integration between
1044 // Pushkin notification service and Security Monkey security audit service
1045 timeout(10) {
1046 common.infoMsg("Waiting for Pushkin to come up..")
1047 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1048 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001049 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001050
1051 // Rundeck
1052 timeout(10) {
1053 common.infoMsg("Waiting for Rundeck to come up..")
1054 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1055 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001056 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001057
1058 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001059 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1060 def elasticsearch_vip
1061 if(!pillar['return'].isEmpty()) {
1062 elasticsearch_vip = pillar['return'][0].values()[0]
1063 } else {
1064 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1065 }
1066
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001067 timeout(10) {
1068 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001069 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 +04001070 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001071 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001072}