blob: 4c1822448e6a05518008307148b537d768591f81 [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)
Victor Ryzhenkinf610c572018-05-15 15:22:52 +040048
49 salt.fullRefresh(master, "*")
vrovachevc4424a32018-03-15 17:35:57 +040050 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010051 salt.enforceState(master, '*', ['linux.network.host'])
Ivan Suzdal9a6bc392018-04-26 18:29:56 +040052
53 // Install and configure iptables
54 if (salt.testTarget(master, 'I@iptables:service')) {
55 salt.enforceState(master, 'I@iptables:service', 'iptables')
56 }
sgarbuzbb61e812018-05-03 16:58:40 +030057
58 // Install and configure logrotate
59 if (salt.testTarget(master, 'I@logrotate:server')) {
60 salt.enforceState(master, 'I@logrotate:server', 'logrotate')
61 }
Jakub Josef79ecec32017-02-17 14:36:28 +010062}
63
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010064def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020065 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020066 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020067
68 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010069 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020070 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020071 try {
72 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
73 sleep(5)
74 } catch (Throwable e) {
75 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
76 }
Jakub Josef432e9d92018-02-06 18:28:37 +010077 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010078 if (staticMgmtNet) {
79 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
80 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020081 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010082 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020083 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010084 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020085 sleep(5)
Victor Ryzhenkinf610c572018-05-15 15:22:52 +040086
87 salt.fullRefresh(master, target)
vrovachevc4424a32018-03-15 17:35:57 +040088 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010089 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020090}
91
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010092def installInfraKvm(master) {
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020093 def common = new com.mirantis.mk.Common()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010094 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010095 salt.fullRefresh(master, 'I@linux:system')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020096 def infra_conpund = 'I@salt:control'
97 def minions = []
98 def wait_timeout = 10
99 def retries = wait_timeout * 30
Ales Komarekef2bab62017-04-26 11:48:28 +0200100
Richard Felkl286f25f2017-07-26 14:23:55 +0200101 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100102 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +0100103 salt.enforceState(master, 'I@salt:control', 'libvirt')
104 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100105
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200106 timeout(wait_timeout) {
107 common.infoMsg("Waiting for minions to come up...")
108 if (salt.testTarget(master, infra_conpund)) {
109 // Gathering minions
110 for ( infra_node in salt.getMinionsSorted(master, infra_conpund) ) {
111 def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster')
112 if ( !pillar['return'].isEmpty() ) {
113 for ( cluster in pillar['return'][0].values() ) {
114 def engine = cluster.values()[0]['engine']
115 def domain = cluster.values()[0]['domain']
116 def node = cluster.values()[0]['node']
117 if ( engine == "virt" ) {
118 def nodes = node.values()
119 if ( !nodes.isEmpty() ) {
120 for ( vm in nodes ) {
121 if ( vm['name'] != null ) {
122 def vm_fqdn = vm['name'] + '.' + domain
123 if ( !minions.contains(vm_fqdn) ) {
124 minions.add(vm_fqdn)
125 }
126 }
127 }
128 }
129 }
130 }
131 }
132 }
133 }
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100134
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200135 def minions_compound = minions.join(' or ')
136 common.infoMsg('Waiting for next minions to register: ' + minions_compound,)
137 salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1)
138 common.infoMsg('Waiting for minions to respond')
139 salt.minionsReachable(master, 'I@salt:master', minions_compound )
140
141 }
142
143 common.infoMsg("All minions are up.")
Jakub Josef432e9d92018-02-06 18:28:37 +0100144 salt.fullRefresh(master, '* and not kvm*')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200145
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +0100146}
Jakub Josef79ecec32017-02-17 14:36:28 +0100147
vrovachev1c4770b2017-07-05 13:25:21 +0400148def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +0100149 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100150 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200151
Jakub Josef79ecec32017-02-17 14:36:28 +0100152 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200153 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100154 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100155
Jakub Josef432e9d92018-02-06 18:28:37 +0100156 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100157 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100158 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200159 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200160
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300161 // Ensure glusterfs clusters is ready
162 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100163 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300164 }
165
Jakub Josef79ecec32017-02-17 14:36:28 +0100166 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200167 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100168 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100169 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400170
171 // Check galera status
172 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
173 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300174 // If galera is not enabled check if we need to install mysql:server
175 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100176 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300177 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100178 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300179 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200180 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100181 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200182
vrovachev1c4770b2017-07-05 13:25:21 +0400183 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200184 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400185 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200186 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400187 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200188
vrovachev1c4770b2017-07-05 13:25:21 +0400189 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200190 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100191 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
192 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400193 }
194
195 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200196 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100197 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400198
199 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100200 common.retry(3,5){
201 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
202 }
vrovachev1c4770b2017-07-05 13:25:21 +0400203 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200204
Jakub Josef79ecec32017-02-17 14:36:28 +0100205 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200206 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100207 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400208 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
209 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
210 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200211
Jakub Josef79ecec32017-02-17 14:36:28 +0100212 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200213 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100214 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400215 }
216
217 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200218 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400219 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100220 common.retry(3,5){
221 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
222 }
vrovachev1c4770b2017-07-05 13:25:21 +0400223 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200224
225 // Install redis
226 if (salt.testTarget(master, 'I@redis:server')) {
227 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
228 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
229 }
230 salt.enforceState(master, 'I@redis:server', 'redis')
231 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100232 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400233}
234
235def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100236 def common = new com.mirantis.mk.Common()
237 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
238 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100239}
240
241
Ales Komarekef2bab62017-04-26 11:48:28 +0200242def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100244 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200245
246 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300247 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100248 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300249 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100250 // Install sphinx server
251 if (salt.testTarget(master, 'I@sphinx:server')) {
252 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
253 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300254 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100255 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
256 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300257 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200258
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300260 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100261 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
262 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300263 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100264
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300265 // keystone:client must be called locally
266 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
267 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
268 sleep(30)
269 }
270 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100271 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
272 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300273 }
274 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100275 common.retry(3,5){
276 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
277 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300278 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100279
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300280 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300281 if (salt.testTarget(master, 'I@glance:server')) {
282 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100283 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
284 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300285 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200286
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300287 // Check glance service
288 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100289 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200290 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100291 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300292 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200293
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400294 // Create glance resources
295 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100296 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400297 }
298
Jakub Josef79ecec32017-02-17 14:36:28 +0100299 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300300 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100301 // run on first node first
302 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
303 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300304 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100305 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200306 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100307 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300308 }
309 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200310
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400311 // Create nova resources
312 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100313 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400314 }
315
Jakub Josef79ecec32017-02-17 14:36:28 +0100316 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300317 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100318 // run on first node first
319 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
320 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300321 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100322 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200323 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100324 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300325 }
326 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200327
Jakub Josef79ecec32017-02-17 14:36:28 +0100328 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300329 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100330 // run on first node first
331 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
332 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300333 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100334 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200335 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100336 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300337 }
338 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200339
Jakub Josef79ecec32017-02-17 14:36:28 +0100340 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300341 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100342 // run on first node first
343 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
344 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300345 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100346 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200347 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100348 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300349 }
350 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200351
352 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300353 if (salt.testTarget(master, 'I@nova:controller')) {
354 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
355 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300356
357 // Install ironic service
358 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100359 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
360 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300361 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300362
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200363 // Install manila service
364 if (salt.testTarget(master, 'I@manila:api')) {
365 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
366 salt.enforceState(master, 'I@manila:api', 'manila.api')
367 }
368 if (salt.testTarget(master, 'I@manila:scheduler')) {
369 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
370 }
371
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200372 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300373 if (salt.testTarget(master, 'I@designate:server:enabled')) {
374 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100375 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300376 }
377 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100378 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300379 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100380 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200381 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300382 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400383
384 // Install octavia api service
385 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100386 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100387 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400388 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200389
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200390 // Install DogTag server service
391 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100392 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
393 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200394 }
395
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200396 // Install barbican server service
397 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100398 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
399 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200400 }
401 // Install barbican client
402 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100403 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200404 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100405
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200406 // Install gnocchi server
407 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200408 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200409 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
410 }
411
412 // Install gnocchi statsd
413 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200414 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200415 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
416 }
417
418 // Install panko server
419 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200420 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200421 salt.enforceState(master, 'I@panko:server', 'panko')
422 }
423
Ondrej Smola5908ae62018-01-08 13:42:08 +0100424 // Install ceilometer server
425 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200426 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100427 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100428 }
429
430 // Install aodh server
431 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200432 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100433 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100434 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100435}
436
437
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300438def installIronicConductor(master){
439 def salt = new com.mirantis.mk.Salt()
440
441 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100442 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
443 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300444 }
445 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100446 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300447 }
448
449 if (salt.testTarget(master, 'I@nova:compute')) {
450 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
451 }
452
453 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100454 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300455 }
456 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100457 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300458 }
459}
460
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200461def installManilaShare(master){
462 def salt = new com.mirantis.mk.Salt()
463
464 if (salt.testTarget(master, 'I@manila:share')) {
465 salt.enforceState(master, 'I@manila:share', 'manila.share')
466 }
467 if (salt.testTarget(master, 'I@manila:data')) {
468 salt.enforceState(master, 'I@manila:data', 'manila.data')
469 }
470
471 if (salt.testTarget(master, 'I@manila:client')) {
472 salt.enforceState(master, 'I@manila:client', 'manila.client')
473 }
474}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300475
476
Ales Komarekef2bab62017-04-26 11:48:28 +0200477def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100478 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300479 //run full neutron state on neutron.gateway - this will install
480 //neutron agents in addition to neutron server. Once neutron agents
481 //are up neutron resources can be created without hitting the situation when neutron resources are created
482 //prior to neutron agents which results in creating ports in non-usable state
483 if (salt.testTarget(master, 'I@neutron:gateway')) {
484 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
485 }
486
487 // Create neutron resources - this step was moved here to ensure that
488 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
489 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
490 if (salt.testTarget(master, 'I@neutron:client')) {
491 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
492 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200493
Jakub Josef432e9d92018-02-06 18:28:37 +0100494 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400495
496 // install octavia manager services
497 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100498 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
499 salt.enforceState(master, 'I@octavia:manager', 'octavia')
500 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
501 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400502 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200503}
504
505
506def installOpenstackCompute(master) {
507 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200508 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100509 def compute_compound = 'I@nova:compute'
510 if (salt.testTarget(master, compute_compound)) {
511 // In case if infrastructure nodes are used as nova computes too
512 def gluster_compound = 'I@glusterfs:server'
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200513 def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca'
514 // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers
Oleh Hryhorov73f9fa22018-05-02 17:36:58 +0300515 def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}"
516 if (salt.testTarget(master, hightstateTarget)) {
517 retry(2) {
518 salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client')
519 }
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200520 }
521 // Iterate through salt ca servers and check if they have compute role
522 // TODO: switch to batch once salt 2017.7+ would be used
523 for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) {
524 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
525 if ( target == cmp_target ) {
526 // Enforce highstate one by one on salt ca servers which are compute nodes
527 retry(2) {
528 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
529 }
530 }
531 }
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100532 }
533 // Iterate through glusterfs servers and check if they have compute role
534 // TODO: switch to batch once salt 2017.7+ would be used
535 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
536 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
537 if ( target == cmp_target ) {
538 // Enforce highstate one by one on glusterfs servers which are compute nodes
539 retry(2) {
540 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
541 }
542 }
543 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200544 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200545 }
546}
547
548
549def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200550 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200551 def salt = new com.mirantis.mk.Salt()
552
553
Jakub Josef79ecec32017-02-17 14:36:28 +0100554 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100555 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
556 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200557
Jakub Josef79ecec32017-02-17 14:36:28 +0100558 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100559 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
560 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
561 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100562
Marek Celoud443fb642017-11-22 15:07:12 +0100563 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100564 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100565 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100566 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100567}
568
569
Ales Komarekef2bab62017-04-26 11:48:28 +0200570def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200571 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400572 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100573 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200574 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100575 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100576 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100577
vrovachev4ff77302017-08-09 20:39:57 +0400578 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200579 if (salt.testTarget(master, 'I@opencontrail:compute')) {
580 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
581 }
vrovachev4ff77302017-08-09 20:39:57 +0400582
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200583 if (salt.testTarget(master, 'I@nova:compute')) {
584 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)
585 }
vrovachev4ff77302017-08-09 20:39:57 +0400586
Jakub Josef61463c72018-02-13 16:10:56 +0100587 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400588 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100589 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
590 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400591 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100592}
593
594
Ales Komarekef2bab62017-04-26 11:48:28 +0200595def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100596 def common = new com.mirantis.mk.Common()
597 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
598 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100599}
600
601
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200602def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100603 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200604
Jakub Josef79ecec32017-02-17 14:36:28 +0100605 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200606 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
607 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100608
Marek Celoud029391c2017-11-14 10:06:18 +0100609 if (salt.testTarget(master, 'I@etcd:server:setup')) {
610 // Setup etcd server
611 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
612 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100613
614 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100615 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100616
617 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200618 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100619
620 // Restart kubelet
621 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
622}
623
624
Ales Komarekef2bab62017-04-26 11:48:28 +0200625def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200626 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100627 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200628
629 // Bootstrap all nodes
630 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
631 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
632 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
633
634 // Create and distribute SSL certificates for services using salt state
635 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
636
637 // Install docker
638 salt.enforceState(master, 'I@docker:host', 'docker.host')
639
640 // Install Kubernetes and Calico
641 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
642
Yuriy Taradayab564d72017-10-11 15:14:35 +0400643 // Install Tiller and all configured releases
644 if (salt.testTarget(master, 'I@helm:client')) {
645 salt.enforceState(master, 'I@helm:client', 'helm')
646 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200647}
648
649
Martin Polreich8663a342017-06-30 17:33:08 +0200650def installDockerSwarm(master) {
651 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100652
vrovachev1c4770b2017-07-05 13:25:21 +0400653 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200654 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100655 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
656 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
657 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
658 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200659 sleep(5)
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:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100662 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100663 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200664}
665
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200666
667def installCicd(master) {
668 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100669 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100670
Richard Felklc1aba9b2018-01-02 09:25:20 +0100671 if (salt.testTarget(master, 'I@aptly:publisher')) {
672 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
673 }
674
Richard Felkl6de16762017-11-20 11:42:28 +0100675 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 +0200676 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100677
678 if (salt.testTarget(master, 'I@aptly:server')) {
679 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
680 }
681
682 if (salt.testTarget(master, 'I@openldap:client')) {
683 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
684 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200685
686 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100687 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200688 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100689
Richard Felkl6e208fc2017-12-08 10:18:44 +0100690 withEnv(['ASK_ON_ERROR=false']){
691 retry(2){
692 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100693 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100694 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100695 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100696 throw e //rethrow for retry handler
697 }
698 }
699 retry(2){
700 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100701 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100702 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100703 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100704 throw e //rethrow for retry handler
705 }
706 }
707 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200708}
709
710
Martin Polreich8663a342017-06-30 17:33:08 +0200711def installStacklight(master) {
712 def common = new com.mirantis.mk.Common()
713 def salt = new com.mirantis.mk.Salt()
714
Simon Pasquieref4122c2017-08-25 15:52:07 +0200715 // Install core services for K8S environments:
716 // HAProxy, Nginx and lusterFS clients
717 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200718 if (common.checkContains('STACK_INSTALL', 'k8s')) {
719 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
720 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200721
722 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100723 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200724 }
725
726 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100727 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200728 }
Martin Polreich792f2662017-07-11 13:36:32 +0200729 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200730
731 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100732 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
733 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200734
Martin Polreich8663a342017-06-30 17:33:08 +0200735 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100736 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200737
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400738 // Install Prometheus exporters
739 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100740 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400741 }
742
Martin Polreich8663a342017-06-30 17:33:08 +0200743 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100744 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
745 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
746 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
747 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
748 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
749 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400750
751 //Install InfluxDB
752 if (salt.testTarget(master, 'I@influxdb:server')) {
753 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
754 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
755 }
756
757 //Install Prometheus LTS
758 if (salt.testTarget(master, 'I@prometheus:relay')) {
759 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
760 }
Martin Polreich8663a342017-06-30 17:33:08 +0200761
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400762 // Install service for the log collection
763 if (salt.testTarget(master, 'I@fluentd:agent')) {
764 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
765 } else {
766 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
767 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200768
Ondrej Smola5908ae62018-01-08 13:42:08 +0100769 // Install heka ceilometer collector
770 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100771 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100772 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
773 }
774
Martin Polreich470925a2017-07-06 17:12:59 +0200775 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200776 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100777 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100778 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000779
Martin Polreich792f2662017-07-11 13:36:32 +0200780 // Check galera status
781 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
782 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
783 }
Martin Polreich470925a2017-07-06 17:12:59 +0200784
Martin Polreich8663a342017-06-30 17:33:08 +0200785 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100786 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
787 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
788 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200789 sleep(5)
790
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400791 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100792 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400793
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400794 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400795 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400796 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200797 }
Martin Polreich8663a342017-06-30 17:33:08 +0200798
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100799 // Install sphinx server
800 if (salt.testTarget(master, 'I@sphinx:server')) {
801 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
802 }
803
Martin Polreich8663a342017-06-30 17:33:08 +0200804 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200805 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200806 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200807
Martin Polreich8663a342017-06-30 17:33:08 +0200808 def stacklight_vip
809 if(!pillar['return'].isEmpty()) {
810 stacklight_vip = pillar['return'][0].values()[0]
811 } else {
812 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
813 }
vrovachev1c4770b2017-07-05 13:25:21 +0400814
Martin Polreich305e2222017-07-06 11:33:00 +0200815 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200816 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100817 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200818}
819
820def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200821 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200822
823 // infra install
824 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100825 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
826 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200827
Jakub Josef432e9d92018-02-06 18:28:37 +0100828 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
829 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200830
Jakub Josef432e9d92018-02-06 18:28:37 +0100831 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
832 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200833
Jakub Josef432e9d92018-02-06 18:28:37 +0100834 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
835 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200836
Kalynovskyi3e370112017-06-26 12:48:23 +0300837 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
838 def alarming_service = alarming_service_pillar['return'][0].values()[0]
839
840 switch (alarming_service) {
841 case 'sensu':
842 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100843 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
844 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
845 salt.enforceState(master, 'I@redis:server', 'redis')
846 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300847 default:
848 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100849 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300850 // Stop the Nagios service because the package starts it by default and it will
851 // started later only on the node holding the VIP address
852 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
853 }
854
Jakub Josef432e9d92018-02-06 18:28:37 +0100855 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
856 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200857
858 sleep(10)
859}
860
Martin Polreich8663a342017-06-30 17:33:08 +0200861def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200862 def salt = new com.mirantis.mk.Salt()
863 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200864
Jakub Josef432e9d92018-02-06 18:28:37 +0100865 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200866 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100867 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200868 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
869
870 // Install collectd, heka and sensu services on the nodes, this will also
871 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100872 salt.enforceState(master, '*', 'collectd')
873 salt.enforceState(master, '*', 'salt.minion')
874 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200875
876 // Gather the Grafana metadata as grains
877 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
878
879 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100880 salt.enforceState(master, '*', 'salt.minion.grains')
881 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
882 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200883
884 sleep(5)
885
886 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100887 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200888
889 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100890 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200891
Kalynovskyi3e370112017-06-26 12:48:23 +0300892 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
893 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200894
Kalynovskyi3e370112017-06-26 12:48:23 +0300895 switch (alarming_service) {
896 case 'sensu':
897 // Update Sensu
898 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100899 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300900 default:
901 break
902 // Default is nagios, and was enforced in installStacklightControl()
903 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200904
Jakub Josef432e9d92018-02-06 18:28:37 +0100905 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200906 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
907
Marek Celoudd200cad2017-06-07 10:34:46 +0200908 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100909 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
910 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
911 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200912 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
913
Ales Komarekef2bab62017-04-26 11:48:28 +0200914 // Get the StackLight monitoring VIP addres
915 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
916 //vip=${vip:=172.16.10.253}
917 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200918 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200919 def stacklight_vip = pillar['return'][0].values()[0]
920
921 if (stacklight_vip) {
922 // (re)Start manually the services that are bound to the monitoring VIP
923 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100924 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
925 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
926 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
927 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200928 } else {
929 throw new Exception("Missing stacklight_vip")
930 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100931}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200932
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100933//
934// backups
935//
936
937def installBackup(master, component='common') {
938 def salt = new com.mirantis.mk.Salt()
939 if (component == 'common') {
940 // Install Backupninja
941 if (salt.testTarget(master, 'I@backupninja:client')) {
942 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
943 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100944 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100945 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100946 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100947 }
948 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100949 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100950 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100951 }
952 } else if (component == 'mysql') {
953 // Install Xtrabackup
954 if (salt.testTarget(master, 'I@xtrabackup:client')) {
955 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
956 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100957 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100958 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
959 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
960 }
961 if (salt.testTarget(master, 'I@xtrabackup:server')) {
962 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
963 }
964 } else if (component == 'contrail') {
965
966 // Install Cassandra backup
967 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
968 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
969 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100970 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100971 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
972 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
973 }
974 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
975 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
976 }
977 // Install Zookeeper backup
978 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
979 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
980 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100981 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100982 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
983 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
984 }
985 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
986 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
987 }
988 } else if (component == 'ceph') {
989 // Install Ceph backup
990 if (salt.testTarget(master, 'I@ceph:backup:client')) {
991 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
992 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100993 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100994 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100995 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100996 }
997 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100998 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100999 }
1000 }
1001
1002}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001003
1004//
1005// Ceph
1006//
1007
Tomáš Kukráled27a472017-08-29 10:26:25 +02001008def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001009 def salt = new com.mirantis.mk.Salt()
1010
Jakub Josef432e9d92018-02-06 18:28:37 +01001011 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +02001012
Jiri Broulike57a0242017-10-06 13:38:47 +02001013 // generate keyrings
1014 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001015 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
1016 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
1017 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +02001018 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +02001019 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +02001020 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +01001021 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +02001022 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001023 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +02001024 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001025}
1026
Tomáš Kukráled27a472017-08-29 10:26:25 +02001027def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001028 def salt = new com.mirantis.mk.Salt()
1029
1030 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +01001031 salt.enforceState(master, target, 'ceph.osd')
1032 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1033 salt.enforceState(master, target, 'ceph.osd.custom')
1034 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1035 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001036 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001037
Jiri Broulike57a0242017-10-06 13:38:47 +02001038 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +02001039 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +02001040 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +01001041 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001042 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001043}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001044
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001045def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001046 def salt = new com.mirantis.mk.Salt()
1047
1048 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001049 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001050 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
1051 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +04001052 }
1053 // setup Keystone service and endpoints for swift or / and S3
1054 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001055 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001056 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001057}
Jiri Broulike57a0242017-10-06 13:38:47 +02001058
1059def connectCeph(master) {
1060 def salt = new com.mirantis.mk.Salt()
1061
1062 // connect Ceph to the env
1063 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001064 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001065 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
1066 }
1067 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001068 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001069 }
1070 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001071 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1072 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1073 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001074 }
1075}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001076
1077def installOssInfra(master) {
1078 def common = new com.mirantis.mk.Common()
1079 def salt = new com.mirantis.mk.Salt()
1080
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001081 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001082 def orchestrate = new com.mirantis.mk.Orchestrate()
1083 orchestrate.installInfra(master)
1084 }
1085
1086 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001087 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1088 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1089 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001090 }
1091}
1092
1093def installOss(master) {
1094 def common = new com.mirantis.mk.Common()
1095 def salt = new com.mirantis.mk.Salt()
1096
1097 //Get oss VIP address
1098 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1099 common.prettyPrint(pillar)
1100
1101 def oss_vip
1102 if(!pillar['return'].isEmpty()) {
1103 oss_vip = pillar['return'][0].values()[0]
1104 } else {
1105 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1106 }
1107
1108 // Postgres client - initialize OSS services databases
1109 timeout(120){
1110 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001111 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 +04001112 }
1113 // XXX: first run usually fails on some inserts, but we need to create databases at first
1114 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1115
1116 // Setup postgres database with integration between
1117 // Pushkin notification service and Security Monkey security audit service
1118 timeout(10) {
1119 common.infoMsg("Waiting for Pushkin to come up..")
1120 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1121 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001122 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001123
1124 // Rundeck
1125 timeout(10) {
1126 common.infoMsg("Waiting for Rundeck to come up..")
1127 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1128 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001129 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001130
1131 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001132 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1133 def elasticsearch_vip
1134 if(!pillar['return'].isEmpty()) {
1135 elasticsearch_vip = pillar['return'][0].values()[0]
1136 } else {
1137 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1138 }
1139
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001140 timeout(10) {
1141 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001142 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 +04001143 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001144 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001145}