blob: a0eac4edebae91317551f14516574090efe83d9d [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'])
Jakub Josef79ecec32017-02-17 14:36:28 +010050}
51
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010052def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020053 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020054 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020055
56 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010057 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020058 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020059 try {
60 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
61 sleep(5)
62 } catch (Throwable e) {
63 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
64 }
Jakub Josef432e9d92018-02-06 18:28:37 +010065 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010066 if (staticMgmtNet) {
67 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
68 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020069 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010070 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020071 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010072 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020073 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040074 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010075 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020076}
77
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010078def installInfraKvm(master) {
79 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010080 salt.fullRefresh(master, 'I@linux:system')
Ales Komarekef2bab62017-04-26 11:48:28 +020081
Richard Felkl286f25f2017-07-26 14:23:55 +020082 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010083 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010084 salt.enforceState(master, 'I@salt:control', 'libvirt')
85 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010086
Ales Komarekef2bab62017-04-26 11:48:28 +020087 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010088
Jakub Josef432e9d92018-02-06 18:28:37 +010089 salt.fullRefresh(master, '* and not kvm*')
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010090}
Jakub Josef79ecec32017-02-17 14:36:28 +010091
vrovachev1c4770b2017-07-05 13:25:21 +040092def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +010093 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010094 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020095
Jakub Josef79ecec32017-02-17 14:36:28 +010096 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +020097 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +010098 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010099
Jakub Josef432e9d92018-02-06 18:28:37 +0100100 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100101 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100102 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200103 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200104
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300105 // Ensure glusterfs clusters is ready
106 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100107 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300108 }
109
Jakub Josef79ecec32017-02-17 14:36:28 +0100110 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200111 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100112 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100113 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400114
115 // Check galera status
116 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
117 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300118 // If galera is not enabled check if we need to install mysql:server
119 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100120 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300121 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100122 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300123 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200124 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100125 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200126
vrovachev1c4770b2017-07-05 13:25:21 +0400127 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200128 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400129 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200130 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400131 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200132
vrovachev1c4770b2017-07-05 13:25:21 +0400133 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200134 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100135 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
136 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400137 }
138
139 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200140 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100141 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400142
143 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100144 common.retry(3,5){
145 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
146 }
vrovachev1c4770b2017-07-05 13:25:21 +0400147 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200148
Jakub Josef79ecec32017-02-17 14:36:28 +0100149 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200150 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100151 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400152 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
153 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
154 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200155
Jakub Josef79ecec32017-02-17 14:36:28 +0100156 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200157 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100158 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400159 }
160
161 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200162 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400163 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100164 common.retry(3,5){
165 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
166 }
vrovachev1c4770b2017-07-05 13:25:21 +0400167 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200168
169 // Install redis
170 if (salt.testTarget(master, 'I@redis:server')) {
171 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
172 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
173 }
174 salt.enforceState(master, 'I@redis:server', 'redis')
175 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100176 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400177}
178
179def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100180 def common = new com.mirantis.mk.Common()
181 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
182 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100183}
184
185
Ales Komarekef2bab62017-04-26 11:48:28 +0200186def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100187 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100188 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200189
190 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300191 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100192 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300193 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100194 // Install sphinx server
195 if (salt.testTarget(master, 'I@sphinx:server')) {
196 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
197 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300198 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100199 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
200 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300201 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200202
Jakub Josef79ecec32017-02-17 14:36:28 +0100203 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300204 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100205 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
206 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300207 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100208
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300209 // keystone:client must be called locally
210 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
211 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
212 sleep(30)
213 }
214 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100215 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
216 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300217 }
218 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100219 common.retry(3,5){
220 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
221 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300222 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100223
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300224 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300225 if (salt.testTarget(master, 'I@glance:server')) {
226 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100227 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
228 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300229 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200230
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300231 // Check glance service
232 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100233 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200234 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100235 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300236 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200237
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400238 // Create glance resources
239 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100240 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400241 }
242
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300244 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100245 // run on first node first
246 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
247 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300248 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100249 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200250 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100251 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300252 }
253 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200254
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400255 // Create nova resources
256 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100257 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400258 }
259
Jakub Josef79ecec32017-02-17 14:36:28 +0100260 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300261 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100262 // run on first node first
263 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
264 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300265 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100266 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200267 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100268 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300269 }
270 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200271
Jakub Josef79ecec32017-02-17 14:36:28 +0100272 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300273 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100274 // run on first node first
275 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
276 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300277 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100278 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200279 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100280 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300281 }
282 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200283
Jakub Josef79ecec32017-02-17 14:36:28 +0100284 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300285 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100286 // run on first node first
287 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
288 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300289 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100290 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200291 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100292 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300293 }
294 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200295
296 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300297 if (salt.testTarget(master, 'I@nova:controller')) {
298 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
299 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300300
301 // Install ironic service
302 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100303 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
304 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300305 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300306
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200307 // Install manila service
308 if (salt.testTarget(master, 'I@manila:api')) {
309 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
310 salt.enforceState(master, 'I@manila:api', 'manila.api')
311 }
312 if (salt.testTarget(master, 'I@manila:scheduler')) {
313 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
314 }
315
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200316 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300317 if (salt.testTarget(master, 'I@designate:server:enabled')) {
318 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100319 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300320 }
321 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100322 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300323 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100324 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200325 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300326 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400327
328 // Install octavia api service
329 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100330 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100331 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400332 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200333
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200334 // Install DogTag server service
335 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100336 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
337 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200338 }
339
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200340 // Install barbican server service
341 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100342 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
343 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200344 }
345 // Install barbican client
346 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100347 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200348 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100349
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200350 // Install gnocchi server
351 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200352 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200353 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
354 }
355
356 // Install gnocchi statsd
357 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200358 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200359 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
360 }
361
362 // Install panko server
363 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200364 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200365 salt.enforceState(master, 'I@panko:server', 'panko')
366 }
367
Ondrej Smola5908ae62018-01-08 13:42:08 +0100368 // Install ceilometer server
369 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200370 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100371 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100372 }
373
374 // Install aodh server
375 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200376 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100377 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100378 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100379}
380
381
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300382def installIronicConductor(master){
383 def salt = new com.mirantis.mk.Salt()
384
385 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100386 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
387 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300388 }
389 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100390 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300391 }
392
393 if (salt.testTarget(master, 'I@nova:compute')) {
394 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
395 }
396
397 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100398 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300399 }
400 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100401 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300402 }
403}
404
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200405def installManilaShare(master){
406 def salt = new com.mirantis.mk.Salt()
407
408 if (salt.testTarget(master, 'I@manila:share')) {
409 salt.enforceState(master, 'I@manila:share', 'manila.share')
410 }
411 if (salt.testTarget(master, 'I@manila:data')) {
412 salt.enforceState(master, 'I@manila:data', 'manila.data')
413 }
414
415 if (salt.testTarget(master, 'I@manila:client')) {
416 salt.enforceState(master, 'I@manila:client', 'manila.client')
417 }
418}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300419
420
Ales Komarekef2bab62017-04-26 11:48:28 +0200421def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100422 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300423 //run full neutron state on neutron.gateway - this will install
424 //neutron agents in addition to neutron server. Once neutron agents
425 //are up neutron resources can be created without hitting the situation when neutron resources are created
426 //prior to neutron agents which results in creating ports in non-usable state
427 if (salt.testTarget(master, 'I@neutron:gateway')) {
428 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
429 }
430
431 // Create neutron resources - this step was moved here to ensure that
432 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
433 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
434 if (salt.testTarget(master, 'I@neutron:client')) {
435 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
436 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200437
Jakub Josef432e9d92018-02-06 18:28:37 +0100438 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400439
440 // install octavia manager services
441 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100442 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
443 salt.enforceState(master, 'I@octavia:manager', 'octavia')
444 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
445 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400446 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200447}
448
449
450def installOpenstackCompute(master) {
451 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200452 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100453 def compute_compound = 'I@nova:compute'
454 if (salt.testTarget(master, compute_compound)) {
455 // In case if infrastructure nodes are used as nova computes too
456 def gluster_compound = 'I@glusterfs:server'
457 // Enforce highstate asynchronous only on compute nodes which are not glusterfs servers
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200458 retry(2) {
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100459 salt.enforceHighstateWithExclude(master, compute_compound + ' and not ' + gluster_compound, 'opencontrail.client')
460 }
461 // Iterate through glusterfs servers and check if they have compute role
462 // TODO: switch to batch once salt 2017.7+ would be used
463 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
464 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
465 if ( target == cmp_target ) {
466 // Enforce highstate one by one on glusterfs servers which are compute nodes
467 retry(2) {
468 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
469 }
470 }
471 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200472 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200473 }
474}
475
476
477def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200478 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200479 def salt = new com.mirantis.mk.Salt()
480
481
Jakub Josef79ecec32017-02-17 14:36:28 +0100482 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100483 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
484 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200485
Jakub Josef79ecec32017-02-17 14:36:28 +0100486 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100487 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
488 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
489 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100490
Marek Celoud443fb642017-11-22 15:07:12 +0100491 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100492 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100493 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100494 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100495}
496
497
Ales Komarekef2bab62017-04-26 11:48:28 +0200498def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200499 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400500 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100501 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200502 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100503 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100504 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100505
vrovachev4ff77302017-08-09 20:39:57 +0400506 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200507 if (salt.testTarget(master, 'I@opencontrail:compute')) {
508 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
509 }
vrovachev4ff77302017-08-09 20:39:57 +0400510
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200511 if (salt.testTarget(master, 'I@nova:compute')) {
512 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)
513 }
vrovachev4ff77302017-08-09 20:39:57 +0400514
Jakub Josef61463c72018-02-13 16:10:56 +0100515 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400516 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100517 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
518 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400519 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100520}
521
522
Ales Komarekef2bab62017-04-26 11:48:28 +0200523def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100524 def common = new com.mirantis.mk.Common()
525 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
526 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100527}
528
529
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200530def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100531 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200532
Jakub Josef79ecec32017-02-17 14:36:28 +0100533 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200534 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
535 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100536
Marek Celoud029391c2017-11-14 10:06:18 +0100537 if (salt.testTarget(master, 'I@etcd:server:setup')) {
538 // Setup etcd server
539 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
540 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100541
542 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100543 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100544
545 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200546 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100547
548 // Restart kubelet
549 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
550}
551
552
Ales Komarekef2bab62017-04-26 11:48:28 +0200553def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200554 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100555 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200556
557 // Bootstrap all nodes
558 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
559 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
560 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
561
562 // Create and distribute SSL certificates for services using salt state
563 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
564
565 // Install docker
566 salt.enforceState(master, 'I@docker:host', 'docker.host')
567
568 // Install Kubernetes and Calico
569 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
570
Yuriy Taradayab564d72017-10-11 15:14:35 +0400571 // Install Tiller and all configured releases
572 if (salt.testTarget(master, 'I@helm:client')) {
573 salt.enforceState(master, 'I@helm:client', 'helm')
574 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200575}
576
577
Martin Polreich8663a342017-06-30 17:33:08 +0200578def installDockerSwarm(master) {
579 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100580
vrovachev1c4770b2017-07-05 13:25:21 +0400581 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200582 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100583 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
584 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
585 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
586 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200587 sleep(5)
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:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100590 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100591 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200592}
593
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200594
595def installCicd(master) {
596 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100597 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100598
Richard Felklc1aba9b2018-01-02 09:25:20 +0100599 if (salt.testTarget(master, 'I@aptly:publisher')) {
600 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
601 }
602
Richard Felkl6de16762017-11-20 11:42:28 +0100603 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 +0200604 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100605
606 if (salt.testTarget(master, 'I@aptly:server')) {
607 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
608 }
609
610 if (salt.testTarget(master, 'I@openldap:client')) {
611 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
612 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200613
614 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100615 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200616 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100617
Richard Felkl6e208fc2017-12-08 10:18:44 +0100618 withEnv(['ASK_ON_ERROR=false']){
619 retry(2){
620 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100621 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100622 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100623 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100624 throw e //rethrow for retry handler
625 }
626 }
627 retry(2){
628 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100629 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100630 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100631 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100632 throw e //rethrow for retry handler
633 }
634 }
635 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200636}
637
638
Martin Polreich8663a342017-06-30 17:33:08 +0200639def installStacklight(master) {
640 def common = new com.mirantis.mk.Common()
641 def salt = new com.mirantis.mk.Salt()
642
Simon Pasquieref4122c2017-08-25 15:52:07 +0200643 // Install core services for K8S environments:
644 // HAProxy, Nginx and lusterFS clients
645 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200646 if (common.checkContains('STACK_INSTALL', 'k8s')) {
647 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
648 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200649
650 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100651 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200652 }
653
654 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100655 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200656 }
Martin Polreich792f2662017-07-11 13:36:32 +0200657 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200658
659 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100660 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
661 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200662
Martin Polreich8663a342017-06-30 17:33:08 +0200663 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100664 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200665
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400666 // Install Prometheus exporters
667 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100668 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400669 }
670
Martin Polreich8663a342017-06-30 17:33:08 +0200671 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100672 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
673 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
674 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
675 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
676 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
677 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400678
679 //Install InfluxDB
680 if (salt.testTarget(master, 'I@influxdb:server')) {
681 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
682 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
683 }
684
685 //Install Prometheus LTS
686 if (salt.testTarget(master, 'I@prometheus:relay')) {
687 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
688 }
Martin Polreich8663a342017-06-30 17:33:08 +0200689
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400690 // Install service for the log collection
691 if (salt.testTarget(master, 'I@fluentd:agent')) {
692 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
693 } else {
694 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
695 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200696
Ondrej Smola5908ae62018-01-08 13:42:08 +0100697 // Install heka ceilometer collector
698 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100699 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100700 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
701 }
702
Martin Polreich470925a2017-07-06 17:12:59 +0200703 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200704 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100705 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100706 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000707
Martin Polreich792f2662017-07-11 13:36:32 +0200708 // Check galera status
709 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
710 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
711 }
Martin Polreich470925a2017-07-06 17:12:59 +0200712
Martin Polreich8663a342017-06-30 17:33:08 +0200713 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100714 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
715 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
716 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200717 sleep(5)
718
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400719 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100720 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400721
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400722 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400723 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400724 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200725 }
Martin Polreich8663a342017-06-30 17:33:08 +0200726
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100727 // Install sphinx server
728 if (salt.testTarget(master, 'I@sphinx:server')) {
729 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
730 }
731
Martin Polreich8663a342017-06-30 17:33:08 +0200732 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200733 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200734 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200735
Martin Polreich8663a342017-06-30 17:33:08 +0200736 def stacklight_vip
737 if(!pillar['return'].isEmpty()) {
738 stacklight_vip = pillar['return'][0].values()[0]
739 } else {
740 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
741 }
vrovachev1c4770b2017-07-05 13:25:21 +0400742
Martin Polreich305e2222017-07-06 11:33:00 +0200743 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200744 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100745 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200746}
747
748def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200749 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200750
751 // infra install
752 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100753 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
754 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200755
Jakub Josef432e9d92018-02-06 18:28:37 +0100756 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
757 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200758
Jakub Josef432e9d92018-02-06 18:28:37 +0100759 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
760 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200761
Jakub Josef432e9d92018-02-06 18:28:37 +0100762 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
763 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200764
Kalynovskyi3e370112017-06-26 12:48:23 +0300765 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
766 def alarming_service = alarming_service_pillar['return'][0].values()[0]
767
768 switch (alarming_service) {
769 case 'sensu':
770 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100771 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
772 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
773 salt.enforceState(master, 'I@redis:server', 'redis')
774 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300775 default:
776 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100777 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300778 // Stop the Nagios service because the package starts it by default and it will
779 // started later only on the node holding the VIP address
780 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
781 }
782
Jakub Josef432e9d92018-02-06 18:28:37 +0100783 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
784 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200785
786 sleep(10)
787}
788
Martin Polreich8663a342017-06-30 17:33:08 +0200789def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200790 def salt = new com.mirantis.mk.Salt()
791 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200792
Jakub Josef432e9d92018-02-06 18:28:37 +0100793 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200794 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100795 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200796 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
797
798 // Install collectd, heka and sensu services on the nodes, this will also
799 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100800 salt.enforceState(master, '*', 'collectd')
801 salt.enforceState(master, '*', 'salt.minion')
802 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200803
804 // Gather the Grafana metadata as grains
805 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
806
807 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100808 salt.enforceState(master, '*', 'salt.minion.grains')
809 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
810 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200811
812 sleep(5)
813
814 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100815 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200816
817 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100818 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200819
Kalynovskyi3e370112017-06-26 12:48:23 +0300820 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
821 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200822
Kalynovskyi3e370112017-06-26 12:48:23 +0300823 switch (alarming_service) {
824 case 'sensu':
825 // Update Sensu
826 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100827 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300828 default:
829 break
830 // Default is nagios, and was enforced in installStacklightControl()
831 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200832
Jakub Josef432e9d92018-02-06 18:28:37 +0100833 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200834 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
835
Marek Celoudd200cad2017-06-07 10:34:46 +0200836 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100837 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
838 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
839 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200840 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
841
Ales Komarekef2bab62017-04-26 11:48:28 +0200842 // Get the StackLight monitoring VIP addres
843 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
844 //vip=${vip:=172.16.10.253}
845 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200846 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200847 def stacklight_vip = pillar['return'][0].values()[0]
848
849 if (stacklight_vip) {
850 // (re)Start manually the services that are bound to the monitoring VIP
851 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100852 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
853 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
854 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
855 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200856 } else {
857 throw new Exception("Missing stacklight_vip")
858 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100859}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200860
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100861//
862// backups
863//
864
865def installBackup(master, component='common') {
866 def salt = new com.mirantis.mk.Salt()
867 if (component == 'common') {
868 // Install Backupninja
869 if (salt.testTarget(master, 'I@backupninja:client')) {
870 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
871 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100872 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100873 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100874 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100875 }
876 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100877 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100878 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100879 }
880 } else if (component == 'mysql') {
881 // Install Xtrabackup
882 if (salt.testTarget(master, 'I@xtrabackup:client')) {
883 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
884 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100885 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100886 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
887 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
888 }
889 if (salt.testTarget(master, 'I@xtrabackup:server')) {
890 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
891 }
892 } else if (component == 'contrail') {
893
894 // Install Cassandra backup
895 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
896 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
897 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100898 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100899 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
900 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
901 }
902 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
903 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
904 }
905 // Install Zookeeper backup
906 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
907 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
908 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100909 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100910 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
911 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
912 }
913 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
914 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
915 }
916 } else if (component == 'ceph') {
917 // Install Ceph backup
918 if (salt.testTarget(master, 'I@ceph:backup:client')) {
919 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
920 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100921 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100922 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100923 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100924 }
925 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100926 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100927 }
928 }
929
930}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200931
932//
933// Ceph
934//
935
Tomáš Kukráled27a472017-08-29 10:26:25 +0200936def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200937 def salt = new com.mirantis.mk.Salt()
938
Jakub Josef432e9d92018-02-06 18:28:37 +0100939 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +0200940
Jiri Broulike57a0242017-10-06 13:38:47 +0200941 // generate keyrings
942 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100943 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
944 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
945 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +0200946 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +0200947 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +0200948 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +0100949 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +0200950 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100951 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +0200952 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200953}
954
Tomáš Kukráled27a472017-08-29 10:26:25 +0200955def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200956 def salt = new com.mirantis.mk.Salt()
957
958 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +0100959 salt.enforceState(master, target, 'ceph.osd')
960 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
961 salt.enforceState(master, target, 'ceph.osd.custom')
962 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
963 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100964 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200965
Jiri Broulike57a0242017-10-06 13:38:47 +0200966 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +0200967 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +0200968 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100969 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +0200970 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200971}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200972
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200973def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200974 def salt = new com.mirantis.mk.Salt()
975
976 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200977 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100978 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
979 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +0400980 }
981 // setup Keystone service and endpoints for swift or / and S3
982 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100983 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +0200984 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +0200985}
Jiri Broulike57a0242017-10-06 13:38:47 +0200986
987def connectCeph(master) {
988 def salt = new com.mirantis.mk.Salt()
989
990 // connect Ceph to the env
991 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100992 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200993 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
994 }
995 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100996 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +0200997 }
998 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100999 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1000 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1001 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001002 }
1003}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001004
1005def installOssInfra(master) {
1006 def common = new com.mirantis.mk.Common()
1007 def salt = new com.mirantis.mk.Salt()
1008
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001009 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001010 def orchestrate = new com.mirantis.mk.Orchestrate()
1011 orchestrate.installInfra(master)
1012 }
1013
1014 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001015 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1016 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1017 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001018 }
1019}
1020
1021def installOss(master) {
1022 def common = new com.mirantis.mk.Common()
1023 def salt = new com.mirantis.mk.Salt()
1024
1025 //Get oss VIP address
1026 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1027 common.prettyPrint(pillar)
1028
1029 def oss_vip
1030 if(!pillar['return'].isEmpty()) {
1031 oss_vip = pillar['return'][0].values()[0]
1032 } else {
1033 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1034 }
1035
1036 // Postgres client - initialize OSS services databases
1037 timeout(120){
1038 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001039 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 +04001040 }
1041 // XXX: first run usually fails on some inserts, but we need to create databases at first
1042 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1043
1044 // Setup postgres database with integration between
1045 // Pushkin notification service and Security Monkey security audit service
1046 timeout(10) {
1047 common.infoMsg("Waiting for Pushkin to come up..")
1048 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1049 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001050 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001051
1052 // Rundeck
1053 timeout(10) {
1054 common.infoMsg("Waiting for Rundeck to come up..")
1055 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1056 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001057 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001058
1059 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001060 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1061 def elasticsearch_vip
1062 if(!pillar['return'].isEmpty()) {
1063 elasticsearch_vip = pillar['return'][0].values()[0]
1064 } else {
1065 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1066 }
1067
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001068 timeout(10) {
1069 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001070 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 +04001071 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001072 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001073}