blob: 694aa4f626a2db825de815ff7ce77df09d195c91 [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)
33 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
34 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +010035 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010036 if (staticMgmtNet) {
37 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
38 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +010039 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020040 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020041 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040042 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010043 salt.enforceState(master, '*', ['linux.network.host'])
Jakub Josef79ecec32017-02-17 14:36:28 +010044}
45
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010046def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020047 def salt = new com.mirantis.mk.Salt()
48
49 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010050 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020051 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
52 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
53 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +010054 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010055 if (staticMgmtNet) {
56 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
57 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020058 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010059 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020060
Jiri Broulike3e7bc32018-02-26 10:50:07 +010061 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020062 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040063 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010064 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020065}
66
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010067def installInfraKvm(master) {
68 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010069 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020070
Richard Felkl286f25f2017-07-26 14:23:55 +020071 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010072 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010073 salt.enforceState(master, 'I@salt:control', 'libvirt')
74 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010075
Ales Komarekef2bab62017-04-26 11:48:28 +020076 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010077
Jakub Josef432e9d92018-02-06 18:28:37 +010078 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010079}
Jakub Josef79ecec32017-02-17 14:36:28 +010080
vrovachev1c4770b2017-07-05 13:25:21 +040081def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010082 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010083 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020084
Jakub Josef79ecec32017-02-17 14:36:28 +010085 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020086 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010087 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010088
Jakub Josef432e9d92018-02-06 18:28:37 +010089 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +010090 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +010091 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +020092 }
Ales Komarekef2bab62017-04-26 11:48:28 +020093
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030094 // Ensure glusterfs clusters is ready
95 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010096 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +030097 }
98
Jakub Josef79ecec32017-02-17 14:36:28 +010099 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200100 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100101 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100102 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400103
104 // Check galera status
105 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
106 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300107 // If galera is not enabled check if we need to install mysql:server
108 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100109 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300110 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100111 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300112 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200113 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100114 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200115
vrovachev1c4770b2017-07-05 13:25:21 +0400116 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200117 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400118 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200119 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400120 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200121
vrovachev1c4770b2017-07-05 13:25:21 +0400122 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200123 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100124 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
125 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400126 }
127
128 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200129 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100130 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400131
132 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100133 common.retry(3,5){
134 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
135 }
vrovachev1c4770b2017-07-05 13:25:21 +0400136 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200137
Jakub Josef79ecec32017-02-17 14:36:28 +0100138 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200139 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100140 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400141 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
142 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
143 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200144
Jakub Josef79ecec32017-02-17 14:36:28 +0100145 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200146 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100147 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400148 }
149
150 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200151 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400152 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100153 common.retry(3,5){
154 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
155 }
vrovachev1c4770b2017-07-05 13:25:21 +0400156 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200157
158 // Install redis
159 if (salt.testTarget(master, 'I@redis:server')) {
160 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
161 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
162 }
163 salt.enforceState(master, 'I@redis:server', 'redis')
164 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100165 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400166}
167
168def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100169 def common = new com.mirantis.mk.Common()
170 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
171 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100172}
173
174
Ales Komarekef2bab62017-04-26 11:48:28 +0200175def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100176 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100177 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200178
179 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300180 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100181 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300182 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100183 // Install sphinx server
184 if (salt.testTarget(master, 'I@sphinx:server')) {
185 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
186 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300187 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100188 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
189 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300190 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200191
Jakub Josef79ecec32017-02-17 14:36:28 +0100192 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300193 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100194 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
195 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300196 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100197
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300198 // keystone:client must be called locally
199 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
200 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
201 sleep(30)
202 }
203 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100204 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
205 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 }
207 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100208 common.retry(3,5){
209 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
210 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300211 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100212
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300213 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300214 if (salt.testTarget(master, 'I@glance:server')) {
215 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100216 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
217 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300218 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200219
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300220 // Check glance service
221 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100222 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200223 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100224 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300225 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200226
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400227 // Create glance resources
228 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100229 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400230 }
231
Jakub Josef79ecec32017-02-17 14:36:28 +0100232 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300233 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100234 // run on first node first
235 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
236 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300237 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100238 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200239 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100240 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300241 }
242 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200243
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400244 // Create nova resources
245 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100246 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400247 }
248
Jakub Josef79ecec32017-02-17 14:36:28 +0100249 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300250 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100251 // run on first node first
252 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
253 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300254 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100255 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200256 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100257 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300258 }
259 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200260
Jakub Josef79ecec32017-02-17 14:36:28 +0100261 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300262 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100263 // run on first node first
264 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
265 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300266 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100267 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200268 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100269 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300270 }
271 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200272
Jakub Josef79ecec32017-02-17 14:36:28 +0100273 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300274 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100275 // run on first node first
276 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
277 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300278 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100279 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200280 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100281 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300282 }
283 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200284
285 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300286 if (salt.testTarget(master, 'I@nova:controller')) {
287 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
288 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300289
290 // Install ironic service
291 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100292 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
293 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300294 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300295
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200296 // Install manila service
297 if (salt.testTarget(master, 'I@manila:api')) {
298 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
299 salt.enforceState(master, 'I@manila:api', 'manila.api')
300 }
301 if (salt.testTarget(master, 'I@manila:scheduler')) {
302 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
303 }
304
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200305 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300306 if (salt.testTarget(master, 'I@designate:server:enabled')) {
307 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100308 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300309 }
310 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100311 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300312 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100313 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200314 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300315 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400316
317 // Install octavia api service
318 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100319 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100320 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400321 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200322
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200323 // Install DogTag server service
324 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100325 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
326 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200327 }
328
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200329 // Install barbican server service
330 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100331 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
332 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200333 }
334 // Install barbican client
335 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100336 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200337 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100338
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200339 // Install gnocchi server
340 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200341 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200342 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
343 }
344
345 // Install gnocchi statsd
346 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200347 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200348 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
349 }
350
351 // Install panko server
352 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200353 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200354 salt.enforceState(master, 'I@panko:server', 'panko')
355 }
356
Ondrej Smola5908ae62018-01-08 13:42:08 +0100357 // Install ceilometer server
358 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200359 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100360 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100361 }
362
363 // Install aodh server
364 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200365 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100366 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100367 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100368}
369
370
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300371def installIronicConductor(master){
372 def salt = new com.mirantis.mk.Salt()
373
374 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100375 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
376 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300377 }
378 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100379 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300380 }
381
382 if (salt.testTarget(master, 'I@nova:compute')) {
383 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
384 }
385
386 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100387 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300388 }
389 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100390 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300391 }
392}
393
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200394def installManilaShare(master){
395 def salt = new com.mirantis.mk.Salt()
396
397 if (salt.testTarget(master, 'I@manila:share')) {
398 salt.enforceState(master, 'I@manila:share', 'manila.share')
399 }
400 if (salt.testTarget(master, 'I@manila:data')) {
401 salt.enforceState(master, 'I@manila:data', 'manila.data')
402 }
403
404 if (salt.testTarget(master, 'I@manila:client')) {
405 salt.enforceState(master, 'I@manila:client', 'manila.client')
406 }
407}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300408
409
Ales Komarekef2bab62017-04-26 11:48:28 +0200410def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100411 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300412 //run full neutron state on neutron.gateway - this will install
413 //neutron agents in addition to neutron server. Once neutron agents
414 //are up neutron resources can be created without hitting the situation when neutron resources are created
415 //prior to neutron agents which results in creating ports in non-usable state
416 if (salt.testTarget(master, 'I@neutron:gateway')) {
417 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
418 }
419
420 // Create neutron resources - this step was moved here to ensure that
421 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
422 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
423 if (salt.testTarget(master, 'I@neutron:client')) {
424 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
425 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200426
Jakub Josef432e9d92018-02-06 18:28:37 +0100427 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400428
429 // install octavia manager services
430 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100431 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
432 salt.enforceState(master, 'I@octavia:manager', 'octavia')
433 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
434 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400435 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200436}
437
438
439def installOpenstackCompute(master) {
440 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200441 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100442 def compute_compound = 'I@nova:compute'
443 if (salt.testTarget(master, compute_compound)) {
444 // In case if infrastructure nodes are used as nova computes too
445 def gluster_compound = 'I@glusterfs:server'
446 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200447 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100448 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
449 }
450 // Iterate through glusterfs servers and check if they have compute role
451 // TODO: switch to batch once salt 2017.7+ would be used
452 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
453 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
454 if ( target == cmp_target ) {
455 // Enforce highstate one by one on glusterfs servers which are compute nodes
456 retry(2) {
457 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
458 }
459 }
460 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200461 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200462 }
463}
464
465
466def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200467 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200468 def salt = new com.mirantis.mk.Salt()
469
470
Jakub Josef79ecec32017-02-17 14:36:28 +0100471 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100472 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
473 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200474
Jakub Josef79ecec32017-02-17 14:36:28 +0100475 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100476 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
477 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
478 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100479
Marek Celoud443fb642017-11-22 15:07:12 +0100480 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100481 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100482 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100483 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100484}
485
486
Ales Komarekef2bab62017-04-26 11:48:28 +0200487def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200488 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400489 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100490 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200491 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100492 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100493 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100494
vrovachev4ff77302017-08-09 20:39:57 +0400495 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200496 if (salt.testTarget(master, 'I@opencontrail:compute')) {
497 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
498 }
vrovachev4ff77302017-08-09 20:39:57 +0400499
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200500 if (salt.testTarget(master, 'I@nova:compute')) {
501 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)
502 }
vrovachev4ff77302017-08-09 20:39:57 +0400503
Jakub Josef61463c72018-02-13 16:10:56 +0100504 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400505 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100506 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
507 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400508 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100509}
510
511
Ales Komarekef2bab62017-04-26 11:48:28 +0200512def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100513 def common = new com.mirantis.mk.Common()
514 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
515 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100516}
517
518
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200519def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100520 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200521
Jakub Josef79ecec32017-02-17 14:36:28 +0100522 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200523 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
524 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100525
Marek Celoud029391c2017-11-14 10:06:18 +0100526 if (salt.testTarget(master, 'I@etcd:server:setup')) {
527 // Setup etcd server
528 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
529 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100530
531 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100532 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100533
534 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200535 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100536
537 // Restart kubelet
538 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
539}
540
541
Ales Komarekef2bab62017-04-26 11:48:28 +0200542def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200543 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100544 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200545
546 // Bootstrap all nodes
547 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
548 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
549 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
550
551 // Create and distribute SSL certificates for services using salt state
552 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
553
554 // Install docker
555 salt.enforceState(master, 'I@docker:host', 'docker.host')
556
557 // Install Kubernetes and Calico
558 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
559
Yuriy Taradayab564d72017-10-11 15:14:35 +0400560 // Install Tiller and all configured releases
561 if (salt.testTarget(master, 'I@helm:client')) {
562 salt.enforceState(master, 'I@helm:client', 'helm')
563 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200564}
565
566
Martin Polreich8663a342017-06-30 17:33:08 +0200567def installDockerSwarm(master) {
568 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100569
vrovachev1c4770b2017-07-05 13:25:21 +0400570 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200571 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100572 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
573 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
574 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
575 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200576 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100577 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
578 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100579 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100580 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200581}
582
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200583
584def installCicd(master) {
585 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100586 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100587
Richard Felklc1aba9b2018-01-02 09:25:20 +0100588 if (salt.testTarget(master, 'I@aptly:publisher')) {
589 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
590 }
591
Richard Felkl6de16762017-11-20 11:42:28 +0100592 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 +0200593 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100594
595 if (salt.testTarget(master, 'I@aptly:server')) {
596 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
597 }
598
599 if (salt.testTarget(master, 'I@openldap:client')) {
600 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
601 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200602
603 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100604 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200605 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100606
Richard Felkl6e208fc2017-12-08 10:18:44 +0100607 withEnv(['ASK_ON_ERROR=false']){
608 retry(2){
609 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100610 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100611 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100612 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100613 throw e //rethrow for retry handler
614 }
615 }
616 retry(2){
617 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100618 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100619 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100621 throw e //rethrow for retry handler
622 }
623 }
624 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200625}
626
627
Martin Polreich8663a342017-06-30 17:33:08 +0200628def installStacklight(master) {
629 def common = new com.mirantis.mk.Common()
630 def salt = new com.mirantis.mk.Salt()
631
Simon Pasquieref4122c2017-08-25 15:52:07 +0200632 // Install core services for K8S environments:
633 // HAProxy, Nginx and lusterFS clients
634 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200635 if (common.checkContains('STACK_INSTALL', 'k8s')) {
636 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
637 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200638
639 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100640 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200641 }
642
643 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100644 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200645 }
Martin Polreich792f2662017-07-11 13:36:32 +0200646 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200647
648 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100649 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
650 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200651
Martin Polreich8663a342017-06-30 17:33:08 +0200652 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100653 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200654
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400655 // Install Prometheus exporters
656 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100657 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400658 }
659
Martin Polreich8663a342017-06-30 17:33:08 +0200660 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100661 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
662 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
663 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
664 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
665 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
666 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400667
668 //Install InfluxDB
669 if (salt.testTarget(master, 'I@influxdb:server')) {
670 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
671 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
672 }
673
674 //Install Prometheus LTS
675 if (salt.testTarget(master, 'I@prometheus:relay')) {
676 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
677 }
Martin Polreich8663a342017-06-30 17:33:08 +0200678
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400679 // Install service for the log collection
680 if (salt.testTarget(master, 'I@fluentd:agent')) {
681 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
682 } else {
683 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
684 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200685
Ondrej Smola5908ae62018-01-08 13:42:08 +0100686 // Install heka ceilometer collector
687 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100688 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100689 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
690 }
691
Martin Polreich470925a2017-07-06 17:12:59 +0200692 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200693 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100694 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100695 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000696
Martin Polreich792f2662017-07-11 13:36:32 +0200697 // Check galera status
698 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
699 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
700 }
Martin Polreich470925a2017-07-06 17:12:59 +0200701
Martin Polreich8663a342017-06-30 17:33:08 +0200702 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100703 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
704 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
705 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200706 sleep(5)
707
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400708 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100709 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400710
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400711 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400712 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400713 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200714 }
Martin Polreich8663a342017-06-30 17:33:08 +0200715
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100716 // Install sphinx server
717 if (salt.testTarget(master, 'I@sphinx:server')) {
718 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
719 }
720
Martin Polreich8663a342017-06-30 17:33:08 +0200721 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200722 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200723 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200724
Martin Polreich8663a342017-06-30 17:33:08 +0200725 def stacklight_vip
726 if(!pillar['return'].isEmpty()) {
727 stacklight_vip = pillar['return'][0].values()[0]
728 } else {
729 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
730 }
vrovachev1c4770b2017-07-05 13:25:21 +0400731
Martin Polreich305e2222017-07-06 11:33:00 +0200732 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200733 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100734 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200735}
736
737def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200738 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200739
740 // infra install
741 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100742 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
743 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200744
Jakub Josef432e9d92018-02-06 18:28:37 +0100745 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
746 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200747
Jakub Josef432e9d92018-02-06 18:28:37 +0100748 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
749 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200750
Jakub Josef432e9d92018-02-06 18:28:37 +0100751 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
752 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200753
Kalynovskyi3e370112017-06-26 12:48:23 +0300754 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
755 def alarming_service = alarming_service_pillar['return'][0].values()[0]
756
757 switch (alarming_service) {
758 case 'sensu':
759 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100760 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
761 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
762 salt.enforceState(master, 'I@redis:server', 'redis')
763 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300764 default:
765 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100766 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300767 // Stop the Nagios service because the package starts it by default and it will
768 // started later only on the node holding the VIP address
769 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
770 }
771
Jakub Josef432e9d92018-02-06 18:28:37 +0100772 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
773 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200774
775 sleep(10)
776}
777
Martin Polreich8663a342017-06-30 17:33:08 +0200778def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200779 def salt = new com.mirantis.mk.Salt()
780 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200781
Jakub Josef432e9d92018-02-06 18:28:37 +0100782 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200783 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100784 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200785 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
786
787 // Install collectd, heka and sensu services on the nodes, this will also
788 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100789 salt.enforceState(master, '*', 'collectd')
790 salt.enforceState(master, '*', 'salt.minion')
791 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200792
793 // Gather the Grafana metadata as grains
794 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
795
796 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100797 salt.enforceState(master, '*', 'salt.minion.grains')
798 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
799 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200800
801 sleep(5)
802
803 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100804 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200805
806 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100807 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200808
Kalynovskyi3e370112017-06-26 12:48:23 +0300809 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
810 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200811
Kalynovskyi3e370112017-06-26 12:48:23 +0300812 switch (alarming_service) {
813 case 'sensu':
814 // Update Sensu
815 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100816 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300817 default:
818 break
819 // Default is nagios, and was enforced in installStacklightControl()
820 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200821
Jakub Josef432e9d92018-02-06 18:28:37 +0100822 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200823 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
824
Marek Celoudd200cad2017-06-07 10:34:46 +0200825 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100826 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
827 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
828 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200829 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
830
Ales Komarekef2bab62017-04-26 11:48:28 +0200831 // Get the StackLight monitoring VIP addres
832 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
833 //vip=${vip:=172.16.10.253}
834 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200835 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200836 def stacklight_vip = pillar['return'][0].values()[0]
837
838 if (stacklight_vip) {
839 // (re)Start manually the services that are bound to the monitoring VIP
840 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100841 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
842 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
843 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
844 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200845 } else {
846 throw new Exception("Missing stacklight_vip")
847 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100848}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200849
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100850//
851// backups
852//
853
854def installBackup(master, component='common') {
855 def salt = new com.mirantis.mk.Salt()
856 if (component == 'common') {
857 // Install Backupninja
858 if (salt.testTarget(master, 'I@backupninja:client')) {
859 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
860 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100861 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100862 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100863 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100864 }
865 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100866 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100867 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100868 }
869 } else if (component == 'mysql') {
870 // Install Xtrabackup
871 if (salt.testTarget(master, 'I@xtrabackup:client')) {
872 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
873 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100874 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100875 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
876 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
877 }
878 if (salt.testTarget(master, 'I@xtrabackup:server')) {
879 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
880 }
881 } else if (component == 'contrail') {
882
883 // Install Cassandra backup
884 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
885 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
886 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100887 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100888 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
889 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
890 }
891 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
892 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
893 }
894 // Install Zookeeper backup
895 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
896 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
897 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100898 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100899 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
900 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
901 }
902 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
903 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
904 }
905 } else if (component == 'ceph') {
906 // Install Ceph backup
907 if (salt.testTarget(master, 'I@ceph:backup:client')) {
908 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
909 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100910 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100911 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100912 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100913 }
914 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100915 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100916 }
917 }
918
919}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200920
921//
922// Ceph
923//
924
Tomáš Kukráled27a472017-08-29 10:26:25 +0200925def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200926 def salt = new com.mirantis.mk.Salt()
927
Jakub Josef432e9d92018-02-06 18:28:37 +0100928 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200929
Jiri Broulike57a0242017-10-06 13:38:47 +0200930 // generate keyrings
931 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100932 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
933 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
934 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200935 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200936 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200937 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100938 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200939 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100940 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200941 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200942}
943
Tomáš Kukráled27a472017-08-29 10:26:25 +0200944def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200945 def salt = new com.mirantis.mk.Salt()
946
947 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100948 salt.enforceState(master, target, 'ceph.osd')
949 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
950 salt.enforceState(master, target, 'ceph.osd.custom')
951 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
952 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100953 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200954
Jiri Broulike57a0242017-10-06 13:38:47 +0200955 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200956 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200957 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100958 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200959 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200960}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200961
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200962def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200963 def salt = new com.mirantis.mk.Salt()
964
965 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200966 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100967 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
968 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400969 }
970 // setup Keystone service and endpoints for swift or / and S3
971 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100972 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200973 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200974}
Jiri Broulike57a0242017-10-06 13:38:47 +0200975
976def connectCeph(master) {
977 def salt = new com.mirantis.mk.Salt()
978
979 // connect Ceph to the env
980 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100981 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200982 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
983 }
984 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100985 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200986 }
987 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100988 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
989 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
990 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200991 }
992}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400993
994def installOssInfra(master) {
995 def common = new com.mirantis.mk.Common()
996 def salt = new com.mirantis.mk.Salt()
997
Mikhail Ivanov788996c2017-12-15 14:28:57 +0400998 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +0400999 def orchestrate = new com.mirantis.mk.Orchestrate()
1000 orchestrate.installInfra(master)
1001 }
1002
1003 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001004 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1005 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1006 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001007 }
1008}
1009
1010def installOss(master) {
1011 def common = new com.mirantis.mk.Common()
1012 def salt = new com.mirantis.mk.Salt()
1013
1014 //Get oss VIP address
1015 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1016 common.prettyPrint(pillar)
1017
1018 def oss_vip
1019 if(!pillar['return'].isEmpty()) {
1020 oss_vip = pillar['return'][0].values()[0]
1021 } else {
1022 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1023 }
1024
1025 // Postgres client - initialize OSS services databases
1026 timeout(120){
1027 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001028 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 +04001029 }
1030 // XXX: first run usually fails on some inserts, but we need to create databases at first
1031 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1032
1033 // Setup postgres database with integration between
1034 // Pushkin notification service and Security Monkey security audit service
1035 timeout(10) {
1036 common.infoMsg("Waiting for Pushkin to come up..")
1037 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1038 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001039 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001040
1041 // Rundeck
1042 timeout(10) {
1043 common.infoMsg("Waiting for Rundeck to come up..")
1044 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1045 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001046 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001047
1048 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001049 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1050 def elasticsearch_vip
1051 if(!pillar['return'].isEmpty()) {
1052 elasticsearch_vip = pillar['return'][0].values()[0]
1053 } else {
1054 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1055 }
1056
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001057 timeout(10) {
1058 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001059 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 +04001060 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001061 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001062}