blob: f9a5ab8b0c656a435f618ebeb1fd4f7f691a78ec [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 Broulik94538462018-05-11 15:45:13 +020045 sleep(5)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010046 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020047 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020048 sleep(5)
Victor Ryzhenkinf610c572018-05-15 15:22:52 +040049
50 salt.fullRefresh(master, "*")
vrovachevc4424a32018-03-15 17:35:57 +040051 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010052 salt.enforceState(master, '*', ['linux.network.host'])
Ivan Suzdal9a6bc392018-04-26 18:29:56 +040053
54 // Install and configure iptables
55 if (salt.testTarget(master, 'I@iptables:service')) {
56 salt.enforceState(master, 'I@iptables:service', 'iptables')
57 }
sgarbuzbb61e812018-05-03 16:58:40 +030058
59 // Install and configure logrotate
60 if (salt.testTarget(master, 'I@logrotate:server')) {
61 salt.enforceState(master, 'I@logrotate:server', 'logrotate')
62 }
Jakub Josef79ecec32017-02-17 14:36:28 +010063}
64
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010065def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020066 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020067 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020068
69 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010070 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020071 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020072 try {
73 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
74 sleep(5)
75 } catch (Throwable e) {
76 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
77 }
Jakub Josef432e9d92018-02-06 18:28:37 +010078 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010079 if (staticMgmtNet) {
80 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
81 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020082 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010083 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020084 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulik94538462018-05-11 15:45:13 +020085 sleep(5)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010086 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020087 sleep(5)
Victor Ryzhenkinf610c572018-05-15 15:22:52 +040088
89 salt.fullRefresh(master, target)
vrovachevc4424a32018-03-15 17:35:57 +040090 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010091 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020092}
93
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010094def installInfraKvm(master) {
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020095 def common = new com.mirantis.mk.Common()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010096 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010097 salt.fullRefresh(master, 'I@linux:system')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020098 def infra_conpund = 'I@salt:control'
99 def minions = []
100 def wait_timeout = 10
101 def retries = wait_timeout * 30
Ales Komarekef2bab62017-04-26 11:48:28 +0200102
Richard Felkl286f25f2017-07-26 14:23:55 +0200103 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100104 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +0100105 salt.enforceState(master, 'I@salt:control', 'libvirt')
106 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100107
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200108 timeout(wait_timeout) {
109 common.infoMsg("Waiting for minions to come up...")
110 if (salt.testTarget(master, infra_conpund)) {
111 // Gathering minions
112 for ( infra_node in salt.getMinionsSorted(master, infra_conpund) ) {
113 def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster')
114 if ( !pillar['return'].isEmpty() ) {
115 for ( cluster in pillar['return'][0].values() ) {
116 def engine = cluster.values()[0]['engine']
117 def domain = cluster.values()[0]['domain']
118 def node = cluster.values()[0]['node']
119 if ( engine == "virt" ) {
120 def nodes = node.values()
121 if ( !nodes.isEmpty() ) {
122 for ( vm in nodes ) {
123 if ( vm['name'] != null ) {
124 def vm_fqdn = vm['name'] + '.' + domain
125 if ( !minions.contains(vm_fqdn) ) {
126 minions.add(vm_fqdn)
127 }
128 }
129 }
130 }
131 }
132 }
133 }
134 }
135 }
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100136
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200137 def minions_compound = minions.join(' or ')
138 common.infoMsg('Waiting for next minions to register: ' + minions_compound,)
139 salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1)
140 common.infoMsg('Waiting for minions to respond')
141 salt.minionsReachable(master, 'I@salt:master', minions_compound )
142
143 }
144
145 common.infoMsg("All minions are up.")
Jakub Josef432e9d92018-02-06 18:28:37 +0100146 salt.fullRefresh(master, '* and not kvm*')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200147
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +0100148}
Jakub Josef79ecec32017-02-17 14:36:28 +0100149
vrovachev1c4770b2017-07-05 13:25:21 +0400150def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +0100151 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100152 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200153
Jakub Josef79ecec32017-02-17 14:36:28 +0100154 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200155 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100156 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100157
Jakub Josef432e9d92018-02-06 18:28:37 +0100158 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100159 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100160 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200161 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200162
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300163 // Ensure glusterfs clusters is ready
164 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100165 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300166 }
167
Jakub Josef79ecec32017-02-17 14:36:28 +0100168 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200169 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100170 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100171 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400172
173 // Check galera status
174 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
175 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300176 // If galera is not enabled check if we need to install mysql:server
177 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100178 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300179 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100180 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300181 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200182 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100183 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200184
vrovachev1c4770b2017-07-05 13:25:21 +0400185 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200186 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400187 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200188 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400189 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200190
vrovachev1c4770b2017-07-05 13:25:21 +0400191 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200192 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100193 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
194 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400195 }
196
197 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200198 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100199 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400200
201 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100202 common.retry(3,5){
203 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
204 }
vrovachev1c4770b2017-07-05 13:25:21 +0400205 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200206
Jakub Josef79ecec32017-02-17 14:36:28 +0100207 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200208 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100209 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400210 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
211 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
212 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200213
Jakub Josef79ecec32017-02-17 14:36:28 +0100214 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200215 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100216 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400217 }
218
219 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200220 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400221 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100222 common.retry(3,5){
223 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
224 }
vrovachev1c4770b2017-07-05 13:25:21 +0400225 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200226
227 // Install redis
228 if (salt.testTarget(master, 'I@redis:server')) {
229 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
230 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
231 }
232 salt.enforceState(master, 'I@redis:server', 'redis')
233 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100234 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400235}
236
237def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100238 def common = new com.mirantis.mk.Common()
239 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
240 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100241}
242
243
Ales Komarekef2bab62017-04-26 11:48:28 +0200244def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100245 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100246 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200247
248 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300249 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100250 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300251 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100252 // Install sphinx server
253 if (salt.testTarget(master, 'I@sphinx:server')) {
254 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
255 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300256 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100257 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
258 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300259 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200260
Jakub Josef79ecec32017-02-17 14:36:28 +0100261 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300262 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100263 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
264 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300265 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100266
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300267 // keystone:client must be called locally
268 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
269 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
270 sleep(30)
271 }
272 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100273 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
274 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300275 }
276 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100277 common.retry(3,5){
278 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
279 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300280 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100281
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300282 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300283 if (salt.testTarget(master, 'I@glance:server')) {
284 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100285 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
286 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300287 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200288
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300289 // Check glance service
290 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100291 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200292 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100293 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300294 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200295
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400296 // Create glance resources
297 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100298 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400299 }
300
Jakub Josef79ecec32017-02-17 14:36:28 +0100301 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300302 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100303 // run on first node first
304 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
305 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300306 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100307 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200308 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100309 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300310 }
311 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200312
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400313 // Create nova resources
314 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100315 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400316 }
317
Jakub Josef79ecec32017-02-17 14:36:28 +0100318 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300319 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100320 // run on first node first
321 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
322 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300323 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100324 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200325 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100326 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300327 }
328 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200329
Jakub Josef79ecec32017-02-17 14:36:28 +0100330 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300331 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100332 // run on first node first
333 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
334 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300335 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100336 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200337 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100338 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300339 }
340 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200341
Jakub Josef79ecec32017-02-17 14:36:28 +0100342 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300343 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100344 // run on first node first
345 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
346 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300347 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100348 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200349 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100350 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300351 }
352 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200353
354 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300355 if (salt.testTarget(master, 'I@nova:controller')) {
356 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
357 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300358
359 // Install ironic service
360 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100361 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
362 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300363 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300364
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200365 // Install manila service
366 if (salt.testTarget(master, 'I@manila:api')) {
367 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
368 salt.enforceState(master, 'I@manila:api', 'manila.api')
369 }
370 if (salt.testTarget(master, 'I@manila:scheduler')) {
371 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
372 }
373
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200374 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300375 if (salt.testTarget(master, 'I@designate:server:enabled')) {
376 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100377 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300378 }
379 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100380 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300381 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100382 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200383 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300384 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400385
386 // Install octavia api service
387 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100388 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100389 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400390 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200391
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200392 // Install DogTag server service
393 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100394 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
395 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200396 }
397
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200398 // Install barbican server service
399 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100400 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
401 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200402 }
403 // Install barbican client
404 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100405 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200406 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100407
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200408 // Install gnocchi server
409 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200410 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200411 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
412 }
413
414 // Install gnocchi statsd
415 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200416 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200417 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
418 }
419
420 // Install panko server
421 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200422 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200423 salt.enforceState(master, 'I@panko:server', 'panko')
424 }
425
Ondrej Smola5908ae62018-01-08 13:42:08 +0100426 // Install ceilometer server
427 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200428 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100429 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100430 }
431
432 // Install aodh server
433 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200434 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100435 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100436 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100437}
438
439
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300440def installIronicConductor(master){
441 def salt = new com.mirantis.mk.Salt()
442
443 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100444 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
445 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300446 }
447 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100448 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300449 }
450
451 if (salt.testTarget(master, 'I@nova:compute')) {
452 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
453 }
454
455 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100456 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300457 }
458 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100459 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300460 }
461}
462
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200463def installManilaShare(master){
464 def salt = new com.mirantis.mk.Salt()
465
466 if (salt.testTarget(master, 'I@manila:share')) {
467 salt.enforceState(master, 'I@manila:share', 'manila.share')
468 }
469 if (salt.testTarget(master, 'I@manila:data')) {
470 salt.enforceState(master, 'I@manila:data', 'manila.data')
471 }
472
473 if (salt.testTarget(master, 'I@manila:client')) {
474 salt.enforceState(master, 'I@manila:client', 'manila.client')
475 }
476}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300477
478
Ales Komarekef2bab62017-04-26 11:48:28 +0200479def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100480 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300481 //run full neutron state on neutron.gateway - this will install
482 //neutron agents in addition to neutron server. Once neutron agents
483 //are up neutron resources can be created without hitting the situation when neutron resources are created
484 //prior to neutron agents which results in creating ports in non-usable state
485 if (salt.testTarget(master, 'I@neutron:gateway')) {
486 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
487 }
488
489 // Create neutron resources - this step was moved here to ensure that
490 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
491 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
492 if (salt.testTarget(master, 'I@neutron:client')) {
493 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
494 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200495
Jakub Josef432e9d92018-02-06 18:28:37 +0100496 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400497
498 // install octavia manager services
499 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100500 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
501 salt.enforceState(master, 'I@octavia:manager', 'octavia')
502 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
503 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400504 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200505}
506
507
508def installOpenstackCompute(master) {
509 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200510 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100511 def compute_compound = 'I@nova:compute'
512 if (salt.testTarget(master, compute_compound)) {
513 // In case if infrastructure nodes are used as nova computes too
514 def gluster_compound = 'I@glusterfs:server'
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200515 def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca'
516 // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers
Oleh Hryhorov73f9fa22018-05-02 17:36:58 +0300517 def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}"
518 if (salt.testTarget(master, hightstateTarget)) {
519 retry(2) {
520 salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client')
521 }
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200522 }
523 // Iterate through salt ca servers and check if they have compute role
524 // TODO: switch to batch once salt 2017.7+ would be used
525 for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) {
526 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
527 if ( target == cmp_target ) {
528 // Enforce highstate one by one on salt ca servers which are compute nodes
529 retry(2) {
530 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
531 }
532 }
533 }
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100534 }
535 // Iterate through glusterfs servers and check if they have compute role
536 // TODO: switch to batch once salt 2017.7+ would be used
537 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
538 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
539 if ( target == cmp_target ) {
540 // Enforce highstate one by one on glusterfs servers which are compute nodes
541 retry(2) {
542 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
543 }
544 }
545 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200546 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200547 }
548}
549
550
551def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200552 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200553 def salt = new com.mirantis.mk.Salt()
554
555
Jakub Josef79ecec32017-02-17 14:36:28 +0100556 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100557 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
558 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200559
Jakub Josef79ecec32017-02-17 14:36:28 +0100560 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100561 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
562 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
563 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100564
Marek Celoud443fb642017-11-22 15:07:12 +0100565 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100566 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100567 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100568 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100569}
570
571
Ales Komarekef2bab62017-04-26 11:48:28 +0200572def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200573 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400574 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100575 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200576 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100577 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100578 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100579
vrovachev4ff77302017-08-09 20:39:57 +0400580 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200581 if (salt.testTarget(master, 'I@opencontrail:compute')) {
582 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
583 }
vrovachev4ff77302017-08-09 20:39:57 +0400584
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200585 if (salt.testTarget(master, 'I@nova:compute')) {
586 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)
587 }
vrovachev4ff77302017-08-09 20:39:57 +0400588
Jakub Josef61463c72018-02-13 16:10:56 +0100589 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400590 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100591 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
592 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400593 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100594}
595
596
Ales Komarekef2bab62017-04-26 11:48:28 +0200597def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100598 def common = new com.mirantis.mk.Common()
599 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
600 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100601}
602
603
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200604def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100605 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200606
Jakub Josef79ecec32017-02-17 14:36:28 +0100607 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200608 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
609 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100610
Marek Celoud029391c2017-11-14 10:06:18 +0100611 if (salt.testTarget(master, 'I@etcd:server:setup')) {
612 // Setup etcd server
613 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
614 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100615
Victor Ryzhenkinfb5d1b52018-05-22 18:49:26 +0400616 // Run k8s master at *01* to simplify namespaces creation
617 salt.enforceStateWithExclude(master, 'I@kubernetes:master and *01*', "kubernetes.master", "kubernetes.master.setup")
618
Jakub Josef79ecec32017-02-17 14:36:28 +0100619 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100620 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100621
622 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200623 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100624
625 // Restart kubelet
626 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
627}
628
629
Ales Komarekef2bab62017-04-26 11:48:28 +0200630def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200631 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100632 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200633
634 // Bootstrap all nodes
635 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
636 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
637 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
638
639 // Create and distribute SSL certificates for services using salt state
640 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
641
642 // Install docker
643 salt.enforceState(master, 'I@docker:host', 'docker.host')
644
645 // Install Kubernetes and Calico
646 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
647
Yuriy Taradayab564d72017-10-11 15:14:35 +0400648 // Install Tiller and all configured releases
649 if (salt.testTarget(master, 'I@helm:client')) {
650 salt.enforceState(master, 'I@helm:client', 'helm')
651 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200652}
653
654
Martin Polreich8663a342017-06-30 17:33:08 +0200655def installDockerSwarm(master) {
656 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100657
vrovachev1c4770b2017-07-05 13:25:21 +0400658 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200659 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100660 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
661 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
662 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
663 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200664 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100665 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
666 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100667 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100668 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200669}
670
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200671
672def installCicd(master) {
673 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100674 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100675
Richard Felklc1aba9b2018-01-02 09:25:20 +0100676 if (salt.testTarget(master, 'I@aptly:publisher')) {
677 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
678 }
679
Richard Felkl6de16762017-11-20 11:42:28 +0100680 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 +0200681 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100682
683 if (salt.testTarget(master, 'I@aptly:server')) {
684 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
685 }
686
687 if (salt.testTarget(master, 'I@openldap:client')) {
688 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
689 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200690
691 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100692 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200693 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100694
Richard Felkl6e208fc2017-12-08 10:18:44 +0100695 withEnv(['ASK_ON_ERROR=false']){
696 retry(2){
697 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100698 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100699 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100700 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100701 throw e //rethrow for retry handler
702 }
703 }
704 retry(2){
705 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100706 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100707 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100708 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100709 throw e //rethrow for retry handler
710 }
711 }
712 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200713}
714
715
Martin Polreich8663a342017-06-30 17:33:08 +0200716def installStacklight(master) {
717 def common = new com.mirantis.mk.Common()
718 def salt = new com.mirantis.mk.Salt()
719
Simon Pasquieref4122c2017-08-25 15:52:07 +0200720 // Install core services for K8S environments:
721 // HAProxy, Nginx and lusterFS clients
722 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200723 if (common.checkContains('STACK_INSTALL', 'k8s')) {
724 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
725 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200726
727 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100728 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200729 }
730
731 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100732 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200733 }
Martin Polreich792f2662017-07-11 13:36:32 +0200734 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200735
736 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100737 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
738 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200739
Martin Polreich8663a342017-06-30 17:33:08 +0200740 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100741 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200742
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400743 // Install Prometheus exporters
744 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100745 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400746 }
747
Martin Polreich8663a342017-06-30 17:33:08 +0200748 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100749 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
750 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
751 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
752 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
753 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
754 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400755
756 //Install InfluxDB
757 if (salt.testTarget(master, 'I@influxdb:server')) {
758 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
759 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
760 }
761
762 //Install Prometheus LTS
763 if (salt.testTarget(master, 'I@prometheus:relay')) {
764 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
765 }
Martin Polreich8663a342017-06-30 17:33:08 +0200766
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400767 // Install service for the log collection
768 if (salt.testTarget(master, 'I@fluentd:agent')) {
769 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
770 } else {
771 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
772 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200773
Ondrej Smola5908ae62018-01-08 13:42:08 +0100774 // Install heka ceilometer collector
775 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100776 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100777 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
778 }
779
Martin Polreich470925a2017-07-06 17:12:59 +0200780 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200781 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100782 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100783 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000784
Martin Polreich792f2662017-07-11 13:36:32 +0200785 // Check galera status
786 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
787 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
788 }
Martin Polreich470925a2017-07-06 17:12:59 +0200789
Martin Polreich8663a342017-06-30 17:33:08 +0200790 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100791 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
792 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
793 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200794 sleep(5)
795
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400796 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100797 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400798
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400799 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400800 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400801 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200802 }
Martin Polreich8663a342017-06-30 17:33:08 +0200803
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100804 // Install sphinx server
805 if (salt.testTarget(master, 'I@sphinx:server')) {
806 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
807 }
808
Martin Polreich8663a342017-06-30 17:33:08 +0200809 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200810 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200811 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200812
Martin Polreich8663a342017-06-30 17:33:08 +0200813 def stacklight_vip
814 if(!pillar['return'].isEmpty()) {
815 stacklight_vip = pillar['return'][0].values()[0]
816 } else {
817 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
818 }
vrovachev1c4770b2017-07-05 13:25:21 +0400819
Martin Polreich305e2222017-07-06 11:33:00 +0200820 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200821 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100822 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200823}
824
825def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200826 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200827
828 // infra install
829 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100830 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
831 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200832
Jakub Josef432e9d92018-02-06 18:28:37 +0100833 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
834 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200835
Jakub Josef432e9d92018-02-06 18:28:37 +0100836 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
837 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200838
Jakub Josef432e9d92018-02-06 18:28:37 +0100839 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
840 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200841
Kalynovskyi3e370112017-06-26 12:48:23 +0300842 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
843 def alarming_service = alarming_service_pillar['return'][0].values()[0]
844
845 switch (alarming_service) {
846 case 'sensu':
847 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100848 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
849 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
850 salt.enforceState(master, 'I@redis:server', 'redis')
851 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300852 default:
853 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100854 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300855 // Stop the Nagios service because the package starts it by default and it will
856 // started later only on the node holding the VIP address
857 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
858 }
859
Jakub Josef432e9d92018-02-06 18:28:37 +0100860 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
861 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200862
863 sleep(10)
864}
865
Martin Polreich8663a342017-06-30 17:33:08 +0200866def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200867 def salt = new com.mirantis.mk.Salt()
868 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200869
Jakub Josef432e9d92018-02-06 18:28:37 +0100870 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200871 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100872 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200873 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
874
875 // Install collectd, heka and sensu services on the nodes, this will also
876 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100877 salt.enforceState(master, '*', 'collectd')
878 salt.enforceState(master, '*', 'salt.minion')
879 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200880
881 // Gather the Grafana metadata as grains
882 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
883
884 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100885 salt.enforceState(master, '*', 'salt.minion.grains')
886 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
887 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200888
889 sleep(5)
890
891 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100892 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200893
894 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100895 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200896
Kalynovskyi3e370112017-06-26 12:48:23 +0300897 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
898 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200899
Kalynovskyi3e370112017-06-26 12:48:23 +0300900 switch (alarming_service) {
901 case 'sensu':
902 // Update Sensu
903 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100904 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300905 default:
906 break
907 // Default is nagios, and was enforced in installStacklightControl()
908 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200909
Jakub Josef432e9d92018-02-06 18:28:37 +0100910 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200911 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
912
Marek Celoudd200cad2017-06-07 10:34:46 +0200913 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100914 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
915 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
916 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200917 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
918
Ales Komarekef2bab62017-04-26 11:48:28 +0200919 // Get the StackLight monitoring VIP addres
920 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
921 //vip=${vip:=172.16.10.253}
922 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200923 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200924 def stacklight_vip = pillar['return'][0].values()[0]
925
926 if (stacklight_vip) {
927 // (re)Start manually the services that are bound to the monitoring VIP
928 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100929 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
930 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
931 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
932 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200933 } else {
934 throw new Exception("Missing stacklight_vip")
935 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100936}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200937
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100938//
939// backups
940//
941
942def installBackup(master, component='common') {
943 def salt = new com.mirantis.mk.Salt()
944 if (component == 'common') {
945 // Install Backupninja
946 if (salt.testTarget(master, 'I@backupninja:client')) {
947 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
948 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100949 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100950 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100951 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100952 }
953 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100954 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100955 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100956 }
957 } else if (component == 'mysql') {
958 // Install Xtrabackup
959 if (salt.testTarget(master, 'I@xtrabackup:client')) {
960 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
961 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100962 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100963 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
964 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
965 }
966 if (salt.testTarget(master, 'I@xtrabackup:server')) {
967 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
968 }
969 } else if (component == 'contrail') {
970
971 // Install Cassandra backup
972 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
973 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
974 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100975 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100976 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
977 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
978 }
979 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
980 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
981 }
982 // Install Zookeeper backup
983 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
984 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
985 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100986 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100987 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
988 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
989 }
990 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
991 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
992 }
993 } else if (component == 'ceph') {
994 // Install Ceph backup
995 if (salt.testTarget(master, 'I@ceph:backup:client')) {
996 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
997 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100998 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100999 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +01001000 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001001 }
1002 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +01001003 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001004 }
1005 }
1006
1007}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001008
1009//
1010// Ceph
1011//
1012
Tomáš Kukráled27a472017-08-29 10:26:25 +02001013def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001014 def salt = new com.mirantis.mk.Salt()
1015
Jakub Josef432e9d92018-02-06 18:28:37 +01001016 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +02001017
Jiri Broulike57a0242017-10-06 13:38:47 +02001018 // generate keyrings
1019 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001020 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
1021 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
1022 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +02001023 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +02001024 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +02001025 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +01001026 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +02001027 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001028 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +02001029 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001030}
1031
Tomáš Kukráled27a472017-08-29 10:26:25 +02001032def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001033 def salt = new com.mirantis.mk.Salt()
1034
1035 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +01001036 salt.enforceState(master, target, 'ceph.osd')
1037 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1038 salt.enforceState(master, target, 'ceph.osd.custom')
1039 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1040 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001041 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001042
Jiri Broulike57a0242017-10-06 13:38:47 +02001043 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +02001044 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +02001045 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +01001046 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001047 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001048}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001049
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001050def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001051 def salt = new com.mirantis.mk.Salt()
1052
1053 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001054 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001055 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
1056 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +04001057 }
1058 // setup Keystone service and endpoints for swift or / and S3
1059 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001060 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001061 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001062}
Jiri Broulike57a0242017-10-06 13:38:47 +02001063
1064def connectCeph(master) {
1065 def salt = new com.mirantis.mk.Salt()
1066
1067 // connect Ceph to the env
1068 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001069 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001070 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
1071 }
1072 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001073 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001074 }
1075 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001076 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1077 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1078 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001079 }
1080}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001081
1082def installOssInfra(master) {
1083 def common = new com.mirantis.mk.Common()
1084 def salt = new com.mirantis.mk.Salt()
1085
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001086 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001087 def orchestrate = new com.mirantis.mk.Orchestrate()
1088 orchestrate.installInfra(master)
1089 }
1090
1091 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001092 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1093 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1094 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001095 }
1096}
1097
1098def installOss(master) {
1099 def common = new com.mirantis.mk.Common()
1100 def salt = new com.mirantis.mk.Salt()
1101
1102 //Get oss VIP address
1103 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1104 common.prettyPrint(pillar)
1105
1106 def oss_vip
1107 if(!pillar['return'].isEmpty()) {
1108 oss_vip = pillar['return'][0].values()[0]
1109 } else {
1110 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1111 }
1112
1113 // Postgres client - initialize OSS services databases
1114 timeout(120){
1115 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001116 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 +04001117 }
1118 // XXX: first run usually fails on some inserts, but we need to create databases at first
1119 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1120
1121 // Setup postgres database with integration between
1122 // Pushkin notification service and Security Monkey security audit service
1123 timeout(10) {
1124 common.infoMsg("Waiting for Pushkin to come up..")
1125 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1126 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001127 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001128
1129 // Rundeck
1130 timeout(10) {
1131 common.infoMsg("Waiting for Rundeck to come up..")
1132 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1133 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001134 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001135
1136 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001137 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1138 def elasticsearch_vip
1139 if(!pillar['return'].isEmpty()) {
1140 elasticsearch_vip = pillar['return'][0].values()[0]
1141 } else {
1142 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1143 }
1144
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001145 timeout(10) {
1146 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001147 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 +04001148 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001149 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001150}