blob: 02195a7384f3b3ca9051c4d16d9d96d1896be323 [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, "*")
Ondrej Smolaa9b84662018-04-18 11:22:19 +020032 salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020033 try {
34 salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2)
35 sleep(5)
36 } catch (Throwable e) {
37 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
38 }
Jakub Josef432e9d92018-02-06 18:28:37 +010039 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010040 if (staticMgmtNet) {
41 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
42 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +010043 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020044 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020045 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040046 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010047 salt.enforceState(master, '*', ['linux.network.host'])
Jakub Josef79ecec32017-02-17 14:36:28 +010048}
49
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010050def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020051 def salt = new com.mirantis.mk.Salt()
52
53 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010054 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020055 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020056 try {
57 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
58 sleep(5)
59 } catch (Throwable e) {
60 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
61 }
Jakub Josef432e9d92018-02-06 18:28:37 +010062 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010063 if (staticMgmtNet) {
64 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
65 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020066 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010067 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020068
Jiri Broulike3e7bc32018-02-26 10:50:07 +010069 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020070 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040071 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010072 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020073}
74
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010075def installInfraKvm(master) {
76 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010077 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020078
Richard Felkl286f25f2017-07-26 14:23:55 +020079 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010080 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010081 salt.enforceState(master, 'I@salt:control', 'libvirt')
82 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010083
Ales Komarekef2bab62017-04-26 11:48:28 +020084 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010085
Jakub Josef432e9d92018-02-06 18:28:37 +010086 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010087}
Jakub Josef79ecec32017-02-17 14:36:28 +010088
vrovachev1c4770b2017-07-05 13:25:21 +040089def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010090 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010091 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020092
Jakub Josef79ecec32017-02-17 14:36:28 +010093 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020094 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010095 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010096
Jakub Josef432e9d92018-02-06 18:28:37 +010097 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +010098 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +010099 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200100 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200101
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300102 // Ensure glusterfs clusters is ready
103 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100104 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300105 }
106
Jakub Josef79ecec32017-02-17 14:36:28 +0100107 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200108 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100109 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100110 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400111
112 // Check galera status
113 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
114 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300115 // If galera is not enabled check if we need to install mysql:server
116 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100117 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300118 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100119 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300120 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200121 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100122 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200123
vrovachev1c4770b2017-07-05 13:25:21 +0400124 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200125 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400126 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200127 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400128 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200129
vrovachev1c4770b2017-07-05 13:25:21 +0400130 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200131 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100132 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
133 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400134 }
135
136 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200137 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100138 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400139
140 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100141 common.retry(3,5){
142 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
143 }
vrovachev1c4770b2017-07-05 13:25:21 +0400144 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200145
Jakub Josef79ecec32017-02-17 14:36:28 +0100146 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200147 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100148 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400149 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
150 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
151 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200152
Jakub Josef79ecec32017-02-17 14:36:28 +0100153 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200154 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100155 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400156 }
157
158 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200159 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400160 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100161 common.retry(3,5){
162 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
163 }
vrovachev1c4770b2017-07-05 13:25:21 +0400164 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200165
166 // Install redis
167 if (salt.testTarget(master, 'I@redis:server')) {
168 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
169 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
170 }
171 salt.enforceState(master, 'I@redis:server', 'redis')
172 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100173 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400174}
175
176def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100177 def common = new com.mirantis.mk.Common()
178 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
179 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100180}
181
182
Ales Komarekef2bab62017-04-26 11:48:28 +0200183def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100184 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100185 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200186
187 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300188 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100189 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300190 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100191 // Install sphinx server
192 if (salt.testTarget(master, 'I@sphinx:server')) {
193 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
194 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300195 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100196 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
197 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300198 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200199
Jakub Josef79ecec32017-02-17 14:36:28 +0100200 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300201 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100202 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
203 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300204 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100205
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 // keystone:client must be called locally
207 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
208 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
209 sleep(30)
210 }
211 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100212 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
213 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300214 }
215 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100216 common.retry(3,5){
217 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
218 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300219 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100220
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300221 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300222 if (salt.testTarget(master, 'I@glance:server')) {
223 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100224 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
225 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300226 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200227
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300228 // Check glance service
229 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100230 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200231 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100232 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300233 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200234
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400235 // Create glance resources
236 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100237 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400238 }
239
Jakub Josef79ecec32017-02-17 14:36:28 +0100240 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300241 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100242 // run on first node first
243 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
244 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300245 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100246 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200247 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100248 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300249 }
250 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200251
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400252 // Create nova resources
253 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100254 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400255 }
256
Jakub Josef79ecec32017-02-17 14:36:28 +0100257 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300258 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100259 // run on first node first
260 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
261 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300262 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100263 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200264 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100265 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300266 }
267 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200268
Jakub Josef79ecec32017-02-17 14:36:28 +0100269 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300270 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100271 // run on first node first
272 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
273 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300274 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100275 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200276 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100277 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300278 }
279 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200280
Jakub Josef79ecec32017-02-17 14:36:28 +0100281 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300282 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100283 // run on first node first
284 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
285 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300286 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100287 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200288 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100289 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300290 }
291 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200292
293 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300294 if (salt.testTarget(master, 'I@nova:controller')) {
295 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
296 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300297
298 // Install ironic service
299 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100300 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
301 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300302 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300303
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200304 // Install manila service
305 if (salt.testTarget(master, 'I@manila:api')) {
306 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
307 salt.enforceState(master, 'I@manila:api', 'manila.api')
308 }
309 if (salt.testTarget(master, 'I@manila:scheduler')) {
310 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
311 }
312
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200313 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300314 if (salt.testTarget(master, 'I@designate:server:enabled')) {
315 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100316 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300317 }
318 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100319 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300320 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100321 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200322 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300323 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400324
325 // Install octavia api service
326 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100327 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100328 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400329 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200330
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200331 // Install DogTag server service
332 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100333 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
334 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200335 }
336
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200337 // Install barbican server service
338 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100339 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
340 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200341 }
342 // Install barbican client
343 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100344 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200345 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100346
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200347 // Install gnocchi server
348 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200349 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200350 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
351 }
352
353 // Install gnocchi statsd
354 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200355 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200356 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
357 }
358
359 // Install panko server
360 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200361 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200362 salt.enforceState(master, 'I@panko:server', 'panko')
363 }
364
Ondrej Smola5908ae62018-01-08 13:42:08 +0100365 // Install ceilometer server
366 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200367 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100368 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
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()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300420 //run full neutron state on neutron.gateway - this will install
421 //neutron agents in addition to neutron server. Once neutron agents
422 //are up neutron resources can be created without hitting the situation when neutron resources are created
423 //prior to neutron agents which results in creating ports in non-usable state
424 if (salt.testTarget(master, 'I@neutron:gateway')) {
425 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
426 }
427
428 // Create neutron resources - this step was moved here to ensure that
429 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
430 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
431 if (salt.testTarget(master, 'I@neutron:client')) {
432 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
433 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200434
Jakub Josef432e9d92018-02-06 18:28:37 +0100435 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400436
437 // install octavia manager services
438 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100439 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
440 salt.enforceState(master, 'I@octavia:manager', 'octavia')
441 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
442 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400443 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200444}
445
446
447def installOpenstackCompute(master) {
448 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200449 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100450 def compute_compound = 'I@nova:compute'
451 if (salt.testTarget(master, compute_compound)) {
452 // In case if infrastructure nodes are used as nova computes too
453 def gluster_compound = 'I@glusterfs:server'
454 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200455 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100456 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
457 }
458 // Iterate through glusterfs servers and check if they have compute role
459 // TODO: switch to batch once salt 2017.7+ would be used
460 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
461 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
462 if ( target == cmp_target ) {
463 // Enforce highstate one by one on glusterfs servers which are compute nodes
464 retry(2) {
465 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
466 }
467 }
468 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200469 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200470 }
471}
472
473
474def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200475 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200476 def salt = new com.mirantis.mk.Salt()
477
478
Jakub Josef79ecec32017-02-17 14:36:28 +0100479 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100480 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
481 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200482
Jakub Josef79ecec32017-02-17 14:36:28 +0100483 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100484 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
485 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
486 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100487
Marek Celoud443fb642017-11-22 15:07:12 +0100488 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100489 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100490 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100491 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100492}
493
494
Ales Komarekef2bab62017-04-26 11:48:28 +0200495def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200496 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400497 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100498 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200499 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100500 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100501 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100502
vrovachev4ff77302017-08-09 20:39:57 +0400503 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200504 if (salt.testTarget(master, 'I@opencontrail:compute')) {
505 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
506 }
vrovachev4ff77302017-08-09 20:39:57 +0400507
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200508 if (salt.testTarget(master, 'I@nova:compute')) {
509 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)
510 }
vrovachev4ff77302017-08-09 20:39:57 +0400511
Jakub Josef61463c72018-02-13 16:10:56 +0100512 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400513 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100514 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
515 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400516 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100517}
518
519
Ales Komarekef2bab62017-04-26 11:48:28 +0200520def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100521 def common = new com.mirantis.mk.Common()
522 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
523 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100524}
525
526
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200527def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100528 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200529
Jakub Josef79ecec32017-02-17 14:36:28 +0100530 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200531 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
532 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100533
Marek Celoud029391c2017-11-14 10:06:18 +0100534 if (salt.testTarget(master, 'I@etcd:server:setup')) {
535 // Setup etcd server
536 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
537 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100538
539 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100540 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100541
542 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200543 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100544
545 // Restart kubelet
546 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
547}
548
549
Ales Komarekef2bab62017-04-26 11:48:28 +0200550def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200551 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100552 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200553
554 // Bootstrap all nodes
555 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
556 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
557 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
558
559 // Create and distribute SSL certificates for services using salt state
560 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
561
562 // Install docker
563 salt.enforceState(master, 'I@docker:host', 'docker.host')
564
565 // Install Kubernetes and Calico
566 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
567
Yuriy Taradayab564d72017-10-11 15:14:35 +0400568 // Install Tiller and all configured releases
569 if (salt.testTarget(master, 'I@helm:client')) {
570 salt.enforceState(master, 'I@helm:client', 'helm')
571 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200572}
573
574
Martin Polreich8663a342017-06-30 17:33:08 +0200575def installDockerSwarm(master) {
576 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100577
vrovachev1c4770b2017-07-05 13:25:21 +0400578 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200579 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100580 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
581 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
582 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
583 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200584 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100585 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
586 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100587 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100588 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200589}
590
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200591
592def installCicd(master) {
593 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100594 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100595
Richard Felklc1aba9b2018-01-02 09:25:20 +0100596 if (salt.testTarget(master, 'I@aptly:publisher')) {
597 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
598 }
599
Richard Felkl6de16762017-11-20 11:42:28 +0100600 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 +0200601 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100602
603 if (salt.testTarget(master, 'I@aptly:server')) {
604 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
605 }
606
607 if (salt.testTarget(master, 'I@openldap:client')) {
608 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
609 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200610
611 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100612 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200613 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100614
Richard Felkl6e208fc2017-12-08 10:18:44 +0100615 withEnv(['ASK_ON_ERROR=false']){
616 retry(2){
617 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100618 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100619 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100621 throw e //rethrow for retry handler
622 }
623 }
624 retry(2){
625 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100626 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100627 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100628 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100629 throw e //rethrow for retry handler
630 }
631 }
632 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200633}
634
635
Martin Polreich8663a342017-06-30 17:33:08 +0200636def installStacklight(master) {
637 def common = new com.mirantis.mk.Common()
638 def salt = new com.mirantis.mk.Salt()
639
Simon Pasquieref4122c2017-08-25 15:52:07 +0200640 // Install core services for K8S environments:
641 // HAProxy, Nginx and lusterFS clients
642 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200643 if (common.checkContains('STACK_INSTALL', 'k8s')) {
644 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
645 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200646
647 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100648 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200649 }
650
651 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100652 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200653 }
Martin Polreich792f2662017-07-11 13:36:32 +0200654 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200655
656 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100657 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
658 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200659
Martin Polreich8663a342017-06-30 17:33:08 +0200660 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100661 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200662
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400663 // Install Prometheus exporters
664 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100665 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400666 }
667
Martin Polreich8663a342017-06-30 17:33:08 +0200668 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100669 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
670 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
671 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
672 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
673 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
674 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400675
676 //Install InfluxDB
677 if (salt.testTarget(master, 'I@influxdb:server')) {
678 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
679 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
680 }
681
682 //Install Prometheus LTS
683 if (salt.testTarget(master, 'I@prometheus:relay')) {
684 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
685 }
Martin Polreich8663a342017-06-30 17:33:08 +0200686
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400687 // Install service for the log collection
688 if (salt.testTarget(master, 'I@fluentd:agent')) {
689 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
690 } else {
691 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
692 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200693
Ondrej Smola5908ae62018-01-08 13:42:08 +0100694 // Install heka ceilometer collector
695 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100696 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100697 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
698 }
699
Martin Polreich470925a2017-07-06 17:12:59 +0200700 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200701 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100702 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100703 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000704
Martin Polreich792f2662017-07-11 13:36:32 +0200705 // Check galera status
706 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
707 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
708 }
Martin Polreich470925a2017-07-06 17:12:59 +0200709
Martin Polreich8663a342017-06-30 17:33:08 +0200710 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100711 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
712 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
713 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200714 sleep(5)
715
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400716 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100717 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400718
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400719 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400720 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400721 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200722 }
Martin Polreich8663a342017-06-30 17:33:08 +0200723
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100724 // Install sphinx server
725 if (salt.testTarget(master, 'I@sphinx:server')) {
726 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
727 }
728
Martin Polreich8663a342017-06-30 17:33:08 +0200729 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200730 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200731 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200732
Martin Polreich8663a342017-06-30 17:33:08 +0200733 def stacklight_vip
734 if(!pillar['return'].isEmpty()) {
735 stacklight_vip = pillar['return'][0].values()[0]
736 } else {
737 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
738 }
vrovachev1c4770b2017-07-05 13:25:21 +0400739
Martin Polreich305e2222017-07-06 11:33:00 +0200740 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200741 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100742 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200743}
744
745def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200746 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200747
748 // infra install
749 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100750 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
751 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200752
Jakub Josef432e9d92018-02-06 18:28:37 +0100753 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
754 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200755
Jakub Josef432e9d92018-02-06 18:28:37 +0100756 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
757 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200758
Jakub Josef432e9d92018-02-06 18:28:37 +0100759 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
760 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200761
Kalynovskyi3e370112017-06-26 12:48:23 +0300762 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
763 def alarming_service = alarming_service_pillar['return'][0].values()[0]
764
765 switch (alarming_service) {
766 case 'sensu':
767 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100768 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
769 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
770 salt.enforceState(master, 'I@redis:server', 'redis')
771 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300772 default:
773 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100774 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300775 // Stop the Nagios service because the package starts it by default and it will
776 // started later only on the node holding the VIP address
777 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
778 }
779
Jakub Josef432e9d92018-02-06 18:28:37 +0100780 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
781 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200782
783 sleep(10)
784}
785
Martin Polreich8663a342017-06-30 17:33:08 +0200786def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200787 def salt = new com.mirantis.mk.Salt()
788 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200789
Jakub Josef432e9d92018-02-06 18:28:37 +0100790 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200791 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100792 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200793 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
794
795 // Install collectd, heka and sensu services on the nodes, this will also
796 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100797 salt.enforceState(master, '*', 'collectd')
798 salt.enforceState(master, '*', 'salt.minion')
799 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200800
801 // Gather the Grafana metadata as grains
802 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
803
804 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100805 salt.enforceState(master, '*', 'salt.minion.grains')
806 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
807 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200808
809 sleep(5)
810
811 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100812 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200813
814 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100815 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200816
Kalynovskyi3e370112017-06-26 12:48:23 +0300817 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
818 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200819
Kalynovskyi3e370112017-06-26 12:48:23 +0300820 switch (alarming_service) {
821 case 'sensu':
822 // Update Sensu
823 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100824 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300825 default:
826 break
827 // Default is nagios, and was enforced in installStacklightControl()
828 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200829
Jakub Josef432e9d92018-02-06 18:28:37 +0100830 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200831 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
832
Marek Celoudd200cad2017-06-07 10:34:46 +0200833 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100834 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
835 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
836 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200837 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
838
Ales Komarekef2bab62017-04-26 11:48:28 +0200839 // Get the StackLight monitoring VIP addres
840 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
841 //vip=${vip:=172.16.10.253}
842 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200843 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200844 def stacklight_vip = pillar['return'][0].values()[0]
845
846 if (stacklight_vip) {
847 // (re)Start manually the services that are bound to the monitoring VIP
848 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100849 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
850 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
851 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
852 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200853 } else {
854 throw new Exception("Missing stacklight_vip")
855 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100856}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200857
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100858//
859// backups
860//
861
862def installBackup(master, component='common') {
863 def salt = new com.mirantis.mk.Salt()
864 if (component == 'common') {
865 // Install Backupninja
866 if (salt.testTarget(master, 'I@backupninja:client')) {
867 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
868 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100869 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100870 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100871 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100872 }
873 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100874 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100875 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100876 }
877 } else if (component == 'mysql') {
878 // Install Xtrabackup
879 if (salt.testTarget(master, 'I@xtrabackup:client')) {
880 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
881 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100882 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100883 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
884 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
885 }
886 if (salt.testTarget(master, 'I@xtrabackup:server')) {
887 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
888 }
889 } else if (component == 'contrail') {
890
891 // Install Cassandra backup
892 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
893 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
894 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100895 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100896 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
897 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
898 }
899 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
900 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
901 }
902 // Install Zookeeper backup
903 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
904 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
905 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100906 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100907 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
908 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
909 }
910 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
911 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
912 }
913 } else if (component == 'ceph') {
914 // Install Ceph backup
915 if (salt.testTarget(master, 'I@ceph:backup:client')) {
916 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
917 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100918 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100919 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100920 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100921 }
922 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100923 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100924 }
925 }
926
927}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200928
929//
930// Ceph
931//
932
Tomáš Kukráled27a472017-08-29 10:26:25 +0200933def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200934 def salt = new com.mirantis.mk.Salt()
935
Jakub Josef432e9d92018-02-06 18:28:37 +0100936 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200937
Jiri Broulike57a0242017-10-06 13:38:47 +0200938 // generate keyrings
939 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100940 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
941 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
942 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200943 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200944 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200945 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100946 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200947 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100948 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200949 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200950}
951
Tomáš Kukráled27a472017-08-29 10:26:25 +0200952def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200953 def salt = new com.mirantis.mk.Salt()
954
955 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100956 salt.enforceState(master, target, 'ceph.osd')
957 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
958 salt.enforceState(master, target, 'ceph.osd.custom')
959 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
960 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100961 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200962
Jiri Broulike57a0242017-10-06 13:38:47 +0200963 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200964 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200965 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100966 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200967 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200968}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200969
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200970def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200971 def salt = new com.mirantis.mk.Salt()
972
973 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200974 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100975 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
976 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400977 }
978 // setup Keystone service and endpoints for swift or / and S3
979 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100980 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200981 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200982}
Jiri Broulike57a0242017-10-06 13:38:47 +0200983
984def connectCeph(master) {
985 def salt = new com.mirantis.mk.Salt()
986
987 // connect Ceph to the env
988 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100989 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200990 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
991 }
992 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100993 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200994 }
995 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100996 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
997 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
998 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200999 }
1000}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001001
1002def installOssInfra(master) {
1003 def common = new com.mirantis.mk.Common()
1004 def salt = new com.mirantis.mk.Salt()
1005
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001006 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001007 def orchestrate = new com.mirantis.mk.Orchestrate()
1008 orchestrate.installInfra(master)
1009 }
1010
1011 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001012 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1013 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1014 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001015 }
1016}
1017
1018def installOss(master) {
1019 def common = new com.mirantis.mk.Common()
1020 def salt = new com.mirantis.mk.Salt()
1021
1022 //Get oss VIP address
1023 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1024 common.prettyPrint(pillar)
1025
1026 def oss_vip
1027 if(!pillar['return'].isEmpty()) {
1028 oss_vip = pillar['return'][0].values()[0]
1029 } else {
1030 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1031 }
1032
1033 // Postgres client - initialize OSS services databases
1034 timeout(120){
1035 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001036 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 +04001037 }
1038 // XXX: first run usually fails on some inserts, but we need to create databases at first
1039 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1040
1041 // Setup postgres database with integration between
1042 // Pushkin notification service and Security Monkey security audit service
1043 timeout(10) {
1044 common.infoMsg("Waiting for Pushkin to come up..")
1045 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1046 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001047 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001048
1049 // Rundeck
1050 timeout(10) {
1051 common.infoMsg("Waiting for Rundeck to come up..")
1052 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1053 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001054 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001055
1056 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001057 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1058 def elasticsearch_vip
1059 if(!pillar['return'].isEmpty()) {
1060 elasticsearch_vip = pillar['return'][0].values()[0]
1061 } else {
1062 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1063 }
1064
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001065 timeout(10) {
1066 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001067 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 +04001068 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001069 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001070}