blob: a6630d303639dcad945d140587ab3a1f70ad5ad7 [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2/**
3 * Orchestration functions
4 *
5*/
6
7def validateFoundationInfra(master) {
8 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +02009
Jakub Josef432e9d92018-02-06 18:28:37 +010010 salt.cmdRun(master, 'I@salt:master' ,'salt-key')
11 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version')
12 salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top')
13 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory')
14 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top')
Jakub Josef79ecec32017-02-17 14:36:28 +010015}
16
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010017def installFoundationInfra(master, staticMgmtNet=false) {
Jakub Josef79ecec32017-02-17 14:36:28 +010018 def salt = new com.mirantis.mk.Salt()
Jiri Broulik037f8982018-04-23 17:07:16 +020019 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +020020
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020021 // NOTE(vsaienko) Apply reclass first, it may update cluster model
22 // apply linux and salt.master salt.minion states afterwards to make sure
23 // correct cluster model is used.
Jakub Josef432e9d92018-02-06 18:28:37 +010024 salt.enforceState(master, 'I@salt:master', ['reclass'])
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020025
Jakub Josef432e9d92018-02-06 18:28:37 +010026 salt.enforceState(master, 'I@salt:master', ['linux.system'])
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020027 salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010028 salt.fullRefresh(master, "*")
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020029
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030030 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010031 salt.enforceState(master, 'I@salt:master', ['salt.minion'])
32 salt.fullRefresh(master, "*")
Ondrej Smolaa9b84662018-04-18 11:22:19 +020033 salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020034 try {
35 salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2)
36 sleep(5)
37 } catch (Throwable e) {
38 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
39 }
Jakub Josef432e9d92018-02-06 18:28:37 +010040 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010041 if (staticMgmtNet) {
42 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
43 }
Jiri Broulik3740fb92018-04-27 11:52:38 +020044 salt.enforceState(master, 'I@linux:network:interface', ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010045 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020046 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020047 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040048 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010049 salt.enforceState(master, '*', ['linux.network.host'])
Ivan Suzdal9a6bc392018-04-26 18:29:56 +040050
51 // Install and configure iptables
52 if (salt.testTarget(master, 'I@iptables:service')) {
53 salt.enforceState(master, 'I@iptables:service', 'iptables')
54 }
Jakub Josef79ecec32017-02-17 14:36:28 +010055}
56
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010057def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020058 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020059 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020060
61 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010062 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020063 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020064 try {
65 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
66 sleep(5)
67 } catch (Throwable e) {
68 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
69 }
Jakub Josef432e9d92018-02-06 18:28:37 +010070 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010071 if (staticMgmtNet) {
72 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
73 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020074 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010075 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020076 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010077 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020078 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040079 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010080 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020081}
82
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010083def installInfraKvm(master) {
84 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010085 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020086
Richard Felkl286f25f2017-07-26 14:23:55 +020087 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010088 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010089 salt.enforceState(master, 'I@salt:control', 'libvirt')
90 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010091
Ales Komarekef2bab62017-04-26 11:48:28 +020092 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010093
Jakub Josef432e9d92018-02-06 18:28:37 +010094 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010095}
Jakub Josef79ecec32017-02-17 14:36:28 +010096
vrovachev1c4770b2017-07-05 13:25:21 +040097def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010098 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010099 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200100
Jakub Josef79ecec32017-02-17 14:36:28 +0100101 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200102 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100103 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100104
Jakub Josef432e9d92018-02-06 18:28:37 +0100105 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100106 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100107 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200108 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200109
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300110 // Ensure glusterfs clusters is ready
111 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100112 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300113 }
114
Jakub Josef79ecec32017-02-17 14:36:28 +0100115 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200116 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100117 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100118 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400119
120 // Check galera status
121 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
122 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300123 // If galera is not enabled check if we need to install mysql:server
124 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100125 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300126 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100127 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300128 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200129 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100130 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200131
vrovachev1c4770b2017-07-05 13:25:21 +0400132 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200133 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400134 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200135 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400136 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200137
vrovachev1c4770b2017-07-05 13:25:21 +0400138 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200139 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100140 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
141 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400142 }
143
144 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200145 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100146 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400147
148 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100149 common.retry(3,5){
150 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
151 }
vrovachev1c4770b2017-07-05 13:25:21 +0400152 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200153
Jakub Josef79ecec32017-02-17 14:36:28 +0100154 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200155 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100156 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400157 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
158 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
159 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200160
Jakub Josef79ecec32017-02-17 14:36:28 +0100161 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200162 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100163 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400164 }
165
166 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200167 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400168 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100169 common.retry(3,5){
170 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
171 }
vrovachev1c4770b2017-07-05 13:25:21 +0400172 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200173
174 // Install redis
175 if (salt.testTarget(master, 'I@redis:server')) {
176 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
177 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
178 }
179 salt.enforceState(master, 'I@redis:server', 'redis')
180 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100181 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400182}
183
184def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100185 def common = new com.mirantis.mk.Common()
186 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
187 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100188}
189
190
Ales Komarekef2bab62017-04-26 11:48:28 +0200191def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100192 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100193 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200194
195 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300196 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100197 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300198 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100199 // Install sphinx server
200 if (salt.testTarget(master, 'I@sphinx:server')) {
201 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
202 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300203 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100204 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
205 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300206 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200207
Jakub Josef79ecec32017-02-17 14:36:28 +0100208 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300209 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100210 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
211 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300212 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100213
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300214 // keystone:client must be called locally
215 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
216 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
217 sleep(30)
218 }
219 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100220 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
221 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300222 }
223 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100224 common.retry(3,5){
225 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
226 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300227 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100228
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300229 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300230 if (salt.testTarget(master, 'I@glance:server')) {
231 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100232 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
233 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300234 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200235
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300236 // Check glance service
237 if (salt.testTarget(master, 'I@glance: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; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100240 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300241 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200242
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400243 // Create glance resources
244 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100245 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400246 }
247
Jakub Josef79ecec32017-02-17 14:36:28 +0100248 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300249 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100250 // run on first node first
251 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
252 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300253 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100254 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200255 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100256 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300257 }
258 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200259
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400260 // Create nova resources
261 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100262 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400263 }
264
Jakub Josef79ecec32017-02-17 14:36:28 +0100265 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300266 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100267 // run on first node first
268 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
269 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300270 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100271 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200272 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100273 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300274 }
275 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200276
Jakub Josef79ecec32017-02-17 14:36:28 +0100277 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300278 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100279 // run on first node first
280 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
281 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300282 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100283 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200284 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100285 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300286 }
287 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200288
Jakub Josef79ecec32017-02-17 14:36:28 +0100289 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300290 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100291 // run on first node first
292 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
293 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300294 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100295 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200296 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100297 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300298 }
299 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200300
301 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300302 if (salt.testTarget(master, 'I@nova:controller')) {
303 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
304 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300305
306 // Install ironic service
307 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100308 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
309 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300310 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300311
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200312 // Install manila service
313 if (salt.testTarget(master, 'I@manila:api')) {
314 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
315 salt.enforceState(master, 'I@manila:api', 'manila.api')
316 }
317 if (salt.testTarget(master, 'I@manila:scheduler')) {
318 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
319 }
320
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200321 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300322 if (salt.testTarget(master, 'I@designate:server:enabled')) {
323 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100324 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300325 }
326 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100327 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300328 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100329 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200330 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300331 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400332
333 // Install octavia api service
334 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100335 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100336 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400337 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200338
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200339 // Install DogTag server service
340 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100341 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
342 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200343 }
344
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200345 // Install barbican server service
346 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100347 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
348 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200349 }
350 // Install barbican client
351 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100352 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200353 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100354
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200355 // Install gnocchi server
356 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200357 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200358 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
359 }
360
361 // Install gnocchi statsd
362 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200363 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200364 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
365 }
366
367 // Install panko server
368 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200369 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200370 salt.enforceState(master, 'I@panko:server', 'panko')
371 }
372
Ondrej Smola5908ae62018-01-08 13:42:08 +0100373 // Install ceilometer server
374 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200375 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100376 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100377 }
378
379 // Install aodh server
380 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200381 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100382 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100383 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100384}
385
386
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300387def installIronicConductor(master){
388 def salt = new com.mirantis.mk.Salt()
389
390 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100391 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
392 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300393 }
394 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100395 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300396 }
397
398 if (salt.testTarget(master, 'I@nova:compute')) {
399 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
400 }
401
402 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100403 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300404 }
405 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100406 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300407 }
408}
409
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200410def installManilaShare(master){
411 def salt = new com.mirantis.mk.Salt()
412
413 if (salt.testTarget(master, 'I@manila:share')) {
414 salt.enforceState(master, 'I@manila:share', 'manila.share')
415 }
416 if (salt.testTarget(master, 'I@manila:data')) {
417 salt.enforceState(master, 'I@manila:data', 'manila.data')
418 }
419
420 if (salt.testTarget(master, 'I@manila:client')) {
421 salt.enforceState(master, 'I@manila:client', 'manila.client')
422 }
423}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300424
425
Ales Komarekef2bab62017-04-26 11:48:28 +0200426def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100427 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300428 //run full neutron state on neutron.gateway - this will install
429 //neutron agents in addition to neutron server. Once neutron agents
430 //are up neutron resources can be created without hitting the situation when neutron resources are created
431 //prior to neutron agents which results in creating ports in non-usable state
432 if (salt.testTarget(master, 'I@neutron:gateway')) {
433 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
434 }
435
436 // Create neutron resources - this step was moved here to ensure that
437 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
438 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
439 if (salt.testTarget(master, 'I@neutron:client')) {
440 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
441 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200442
Jakub Josef432e9d92018-02-06 18:28:37 +0100443 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400444
445 // install octavia manager services
446 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100447 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
448 salt.enforceState(master, 'I@octavia:manager', 'octavia')
449 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
450 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400451 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200452}
453
454
455def installOpenstackCompute(master) {
456 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200457 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100458 def compute_compound = 'I@nova:compute'
459 if (salt.testTarget(master, compute_compound)) {
460 // In case if infrastructure nodes are used as nova computes too
461 def gluster_compound = 'I@glusterfs:server'
462 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200463 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100464 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
465 }
466 // Iterate through glusterfs servers and check if they have compute role
467 // TODO: switch to batch once salt 2017.7+ would be used
468 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
469 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
470 if ( target == cmp_target ) {
471 // Enforce highstate one by one on glusterfs servers which are compute nodes
472 retry(2) {
473 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
474 }
475 }
476 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200477 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200478 }
479}
480
481
482def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200483 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200484 def salt = new com.mirantis.mk.Salt()
485
486
Jakub Josef79ecec32017-02-17 14:36:28 +0100487 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100488 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
489 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200490
Jakub Josef79ecec32017-02-17 14:36:28 +0100491 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100492 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
493 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
494 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100495
Marek Celoud443fb642017-11-22 15:07:12 +0100496 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100497 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100498 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100499 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100500}
501
502
Ales Komarekef2bab62017-04-26 11:48:28 +0200503def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200504 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400505 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100506 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200507 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100508 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100509 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100510
vrovachev4ff77302017-08-09 20:39:57 +0400511 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200512 if (salt.testTarget(master, 'I@opencontrail:compute')) {
513 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
514 }
vrovachev4ff77302017-08-09 20:39:57 +0400515
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200516 if (salt.testTarget(master, 'I@nova:compute')) {
517 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)
518 }
vrovachev4ff77302017-08-09 20:39:57 +0400519
Jakub Josef61463c72018-02-13 16:10:56 +0100520 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400521 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100522 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
523 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400524 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100525}
526
527
Ales Komarekef2bab62017-04-26 11:48:28 +0200528def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100529 def common = new com.mirantis.mk.Common()
530 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
531 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100532}
533
534
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200535def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100536 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200537
Jakub Josef79ecec32017-02-17 14:36:28 +0100538 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200539 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
540 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100541
Marek Celoud029391c2017-11-14 10:06:18 +0100542 if (salt.testTarget(master, 'I@etcd:server:setup')) {
543 // Setup etcd server
544 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
545 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100546
547 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100548 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100549
550 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200551 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100552
553 // Restart kubelet
554 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
555}
556
557
Ales Komarekef2bab62017-04-26 11:48:28 +0200558def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200559 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100560 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200561
562 // Bootstrap all nodes
563 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
564 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
565 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
566
567 // Create and distribute SSL certificates for services using salt state
568 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
569
570 // Install docker
571 salt.enforceState(master, 'I@docker:host', 'docker.host')
572
573 // Install Kubernetes and Calico
574 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
575
Yuriy Taradayab564d72017-10-11 15:14:35 +0400576 // Install Tiller and all configured releases
577 if (salt.testTarget(master, 'I@helm:client')) {
578 salt.enforceState(master, 'I@helm:client', 'helm')
579 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200580}
581
582
Martin Polreich8663a342017-06-30 17:33:08 +0200583def installDockerSwarm(master) {
584 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100585
vrovachev1c4770b2017-07-05 13:25:21 +0400586 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200587 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100588 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
589 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
590 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
591 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200592 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100593 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
594 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100595 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100596 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200597}
598
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200599
600def installCicd(master) {
601 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100602 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100603
Richard Felklc1aba9b2018-01-02 09:25:20 +0100604 if (salt.testTarget(master, 'I@aptly:publisher')) {
605 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
606 }
607
Richard Felkl6de16762017-11-20 11:42:28 +0100608 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 +0200609 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100610
611 if (salt.testTarget(master, 'I@aptly:server')) {
612 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
613 }
614
615 if (salt.testTarget(master, 'I@openldap:client')) {
616 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
617 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200618
619 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200621 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100622
Richard Felkl6e208fc2017-12-08 10:18:44 +0100623 withEnv(['ASK_ON_ERROR=false']){
624 retry(2){
625 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100626 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100627 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100628 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100629 throw e //rethrow for retry handler
630 }
631 }
632 retry(2){
633 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100634 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100635 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100636 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100637 throw e //rethrow for retry handler
638 }
639 }
640 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200641}
642
643
Martin Polreich8663a342017-06-30 17:33:08 +0200644def installStacklight(master) {
645 def common = new com.mirantis.mk.Common()
646 def salt = new com.mirantis.mk.Salt()
647
Simon Pasquieref4122c2017-08-25 15:52:07 +0200648 // Install core services for K8S environments:
649 // HAProxy, Nginx and lusterFS clients
650 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200651 if (common.checkContains('STACK_INSTALL', 'k8s')) {
652 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
653 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200654
655 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100656 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200657 }
658
659 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100660 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200661 }
Martin Polreich792f2662017-07-11 13:36:32 +0200662 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200663
664 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100665 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
666 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200667
Martin Polreich8663a342017-06-30 17:33:08 +0200668 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100669 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200670
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400671 // Install Prometheus exporters
672 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100673 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400674 }
675
Martin Polreich8663a342017-06-30 17:33:08 +0200676 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100677 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
678 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
679 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
680 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
681 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
682 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400683
684 //Install InfluxDB
685 if (salt.testTarget(master, 'I@influxdb:server')) {
686 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
687 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
688 }
689
690 //Install Prometheus LTS
691 if (salt.testTarget(master, 'I@prometheus:relay')) {
692 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
693 }
Martin Polreich8663a342017-06-30 17:33:08 +0200694
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400695 // Install service for the log collection
696 if (salt.testTarget(master, 'I@fluentd:agent')) {
697 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
698 } else {
699 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
700 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200701
Ondrej Smola5908ae62018-01-08 13:42:08 +0100702 // Install heka ceilometer collector
703 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100704 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100705 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
706 }
707
Martin Polreich470925a2017-07-06 17:12:59 +0200708 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200709 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100710 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100711 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000712
Martin Polreich792f2662017-07-11 13:36:32 +0200713 // Check galera status
714 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
715 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
716 }
Martin Polreich470925a2017-07-06 17:12:59 +0200717
Martin Polreich8663a342017-06-30 17:33:08 +0200718 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100719 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
720 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
721 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200722 sleep(5)
723
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400724 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100725 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400726
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400727 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400728 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400729 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200730 }
Martin Polreich8663a342017-06-30 17:33:08 +0200731
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100732 // Install sphinx server
733 if (salt.testTarget(master, 'I@sphinx:server')) {
734 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
735 }
736
Martin Polreich8663a342017-06-30 17:33:08 +0200737 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200738 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200739 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200740
Martin Polreich8663a342017-06-30 17:33:08 +0200741 def stacklight_vip
742 if(!pillar['return'].isEmpty()) {
743 stacklight_vip = pillar['return'][0].values()[0]
744 } else {
745 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
746 }
vrovachev1c4770b2017-07-05 13:25:21 +0400747
Martin Polreich305e2222017-07-06 11:33:00 +0200748 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200749 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100750 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200751}
752
753def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200754 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200755
756 // infra install
757 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100758 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
759 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200760
Jakub Josef432e9d92018-02-06 18:28:37 +0100761 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
762 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200763
Jakub Josef432e9d92018-02-06 18:28:37 +0100764 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
765 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200766
Jakub Josef432e9d92018-02-06 18:28:37 +0100767 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
768 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200769
Kalynovskyi3e370112017-06-26 12:48:23 +0300770 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
771 def alarming_service = alarming_service_pillar['return'][0].values()[0]
772
773 switch (alarming_service) {
774 case 'sensu':
775 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100776 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
777 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
778 salt.enforceState(master, 'I@redis:server', 'redis')
779 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300780 default:
781 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100782 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300783 // Stop the Nagios service because the package starts it by default and it will
784 // started later only on the node holding the VIP address
785 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
786 }
787
Jakub Josef432e9d92018-02-06 18:28:37 +0100788 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
789 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200790
791 sleep(10)
792}
793
Martin Polreich8663a342017-06-30 17:33:08 +0200794def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200795 def salt = new com.mirantis.mk.Salt()
796 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200797
Jakub Josef432e9d92018-02-06 18:28:37 +0100798 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200799 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100800 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200801 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
802
803 // Install collectd, heka and sensu services on the nodes, this will also
804 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100805 salt.enforceState(master, '*', 'collectd')
806 salt.enforceState(master, '*', 'salt.minion')
807 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200808
809 // Gather the Grafana metadata as grains
810 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
811
812 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100813 salt.enforceState(master, '*', 'salt.minion.grains')
814 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
815 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200816
817 sleep(5)
818
819 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100820 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200821
822 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100823 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200824
Kalynovskyi3e370112017-06-26 12:48:23 +0300825 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
826 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200827
Kalynovskyi3e370112017-06-26 12:48:23 +0300828 switch (alarming_service) {
829 case 'sensu':
830 // Update Sensu
831 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100832 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300833 default:
834 break
835 // Default is nagios, and was enforced in installStacklightControl()
836 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200837
Jakub Josef432e9d92018-02-06 18:28:37 +0100838 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200839 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
840
Marek Celoudd200cad2017-06-07 10:34:46 +0200841 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100842 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
843 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
844 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200845 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
846
Ales Komarekef2bab62017-04-26 11:48:28 +0200847 // Get the StackLight monitoring VIP addres
848 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
849 //vip=${vip:=172.16.10.253}
850 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200851 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200852 def stacklight_vip = pillar['return'][0].values()[0]
853
854 if (stacklight_vip) {
855 // (re)Start manually the services that are bound to the monitoring VIP
856 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100857 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
858 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
859 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
860 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200861 } else {
862 throw new Exception("Missing stacklight_vip")
863 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100864}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200865
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100866//
867// backups
868//
869
870def installBackup(master, component='common') {
871 def salt = new com.mirantis.mk.Salt()
872 if (component == 'common') {
873 // Install Backupninja
874 if (salt.testTarget(master, 'I@backupninja:client')) {
875 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
876 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100877 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100878 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100879 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100880 }
881 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100882 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100883 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100884 }
885 } else if (component == 'mysql') {
886 // Install Xtrabackup
887 if (salt.testTarget(master, 'I@xtrabackup:client')) {
888 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
889 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100890 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100891 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
892 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
893 }
894 if (salt.testTarget(master, 'I@xtrabackup:server')) {
895 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
896 }
897 } else if (component == 'contrail') {
898
899 // Install Cassandra backup
900 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
901 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
902 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100903 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100904 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
905 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
906 }
907 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
908 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
909 }
910 // Install Zookeeper backup
911 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
912 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
913 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100914 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100915 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
916 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
917 }
918 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
919 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
920 }
921 } else if (component == 'ceph') {
922 // Install Ceph backup
923 if (salt.testTarget(master, 'I@ceph:backup:client')) {
924 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
925 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100926 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100927 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100928 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100929 }
930 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100931 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100932 }
933 }
934
935}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200936
937//
938// Ceph
939//
940
Tomáš Kukráled27a472017-08-29 10:26:25 +0200941def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200942 def salt = new com.mirantis.mk.Salt()
943
Jakub Josef432e9d92018-02-06 18:28:37 +0100944 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200945
Jiri Broulike57a0242017-10-06 13:38:47 +0200946 // generate keyrings
947 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100948 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
949 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
950 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200951 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200952 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200953 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100954 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200955 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100956 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200957 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200958}
959
Tomáš Kukráled27a472017-08-29 10:26:25 +0200960def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200961 def salt = new com.mirantis.mk.Salt()
962
963 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100964 salt.enforceState(master, target, 'ceph.osd')
965 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
966 salt.enforceState(master, target, 'ceph.osd.custom')
967 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
968 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100969 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200970
Jiri Broulike57a0242017-10-06 13:38:47 +0200971 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200972 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200973 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100974 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200975 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200976}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200977
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200978def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200979 def salt = new com.mirantis.mk.Salt()
980
981 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200982 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100983 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
984 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400985 }
986 // setup Keystone service and endpoints for swift or / and S3
987 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100988 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200989 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200990}
Jiri Broulike57a0242017-10-06 13:38:47 +0200991
992def connectCeph(master) {
993 def salt = new com.mirantis.mk.Salt()
994
995 // connect Ceph to the env
996 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100997 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200998 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
999 }
1000 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001001 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001002 }
1003 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001004 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1005 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1006 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001007 }
1008}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001009
1010def installOssInfra(master) {
1011 def common = new com.mirantis.mk.Common()
1012 def salt = new com.mirantis.mk.Salt()
1013
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001014 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001015 def orchestrate = new com.mirantis.mk.Orchestrate()
1016 orchestrate.installInfra(master)
1017 }
1018
1019 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001020 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1021 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1022 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001023 }
1024}
1025
1026def installOss(master) {
1027 def common = new com.mirantis.mk.Common()
1028 def salt = new com.mirantis.mk.Salt()
1029
1030 //Get oss VIP address
1031 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1032 common.prettyPrint(pillar)
1033
1034 def oss_vip
1035 if(!pillar['return'].isEmpty()) {
1036 oss_vip = pillar['return'][0].values()[0]
1037 } else {
1038 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1039 }
1040
1041 // Postgres client - initialize OSS services databases
1042 timeout(120){
1043 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001044 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 +04001045 }
1046 // XXX: first run usually fails on some inserts, but we need to create databases at first
1047 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1048
1049 // Setup postgres database with integration between
1050 // Pushkin notification service and Security Monkey security audit service
1051 timeout(10) {
1052 common.infoMsg("Waiting for Pushkin to come up..")
1053 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1054 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001055 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001056
1057 // Rundeck
1058 timeout(10) {
1059 common.infoMsg("Waiting for Rundeck to come up..")
1060 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1061 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001062 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001063
1064 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001065 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1066 def elasticsearch_vip
1067 if(!pillar['return'].isEmpty()) {
1068 elasticsearch_vip = pillar['return'][0].values()[0]
1069 } else {
1070 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1071 }
1072
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001073 timeout(10) {
1074 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001075 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 +04001076 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001077 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001078}