blob: 9e814152bda129284ccb99cb4136730214b0daf5 [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)
vrovachevc4424a32018-03-15 17:35:57 +040049 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010050 salt.enforceState(master, '*', ['linux.network.host'])
Ivan Suzdal9a6bc392018-04-26 18:29:56 +040051
52 // Install and configure iptables
53 if (salt.testTarget(master, 'I@iptables:service')) {
54 salt.enforceState(master, 'I@iptables:service', 'iptables')
55 }
sgarbuzbb61e812018-05-03 16:58:40 +030056
57 // Install and configure logrotate
58 if (salt.testTarget(master, 'I@logrotate:server')) {
59 salt.enforceState(master, 'I@logrotate:server', 'logrotate')
60 }
Jakub Josef79ecec32017-02-17 14:36:28 +010061}
62
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010063def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020064 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020065 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020066
67 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010068 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020069 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020070 try {
71 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
72 sleep(5)
73 } catch (Throwable e) {
74 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
75 }
Jakub Josef432e9d92018-02-06 18:28:37 +010076 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010077 if (staticMgmtNet) {
78 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
79 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020080 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010081 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020082 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulik94538462018-05-11 15:45:13 +020083 sleep(5)
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)
vrovachevc4424a32018-03-15 17:35:57 +040086 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010087 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020088}
89
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010090def installInfraKvm(master) {
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020091 def common = new com.mirantis.mk.Common()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010092 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010093 salt.fullRefresh(master, 'I@linux:system')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020094 def infra_conpund = 'I@salt:control'
95 def minions = []
96 def wait_timeout = 10
97 def retries = wait_timeout * 30
Ales Komarekef2bab62017-04-26 11:48:28 +020098
Richard Felkl286f25f2017-07-26 14:23:55 +020099 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100100 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +0100101 salt.enforceState(master, 'I@salt:control', 'libvirt')
102 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100103
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200104 timeout(wait_timeout) {
105 common.infoMsg("Waiting for minions to come up...")
106 if (salt.testTarget(master, infra_conpund)) {
107 // Gathering minions
108 for ( infra_node in salt.getMinionsSorted(master, infra_conpund) ) {
109 def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster')
110 if ( !pillar['return'].isEmpty() ) {
111 for ( cluster in pillar['return'][0].values() ) {
112 def engine = cluster.values()[0]['engine']
113 def domain = cluster.values()[0]['domain']
114 def node = cluster.values()[0]['node']
115 if ( engine == "virt" ) {
116 def nodes = node.values()
117 if ( !nodes.isEmpty() ) {
118 for ( vm in nodes ) {
119 if ( vm['name'] != null ) {
120 def vm_fqdn = vm['name'] + '.' + domain
121 if ( !minions.contains(vm_fqdn) ) {
122 minions.add(vm_fqdn)
123 }
124 }
125 }
126 }
127 }
128 }
129 }
130 }
131 }
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100132
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200133 def minions_compound = minions.join(' or ')
134 common.infoMsg('Waiting for next minions to register: ' + minions_compound,)
135 salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1)
136 common.infoMsg('Waiting for minions to respond')
137 salt.minionsReachable(master, 'I@salt:master', minions_compound )
138
139 }
140
141 common.infoMsg("All minions are up.")
Jakub Josef432e9d92018-02-06 18:28:37 +0100142 salt.fullRefresh(master, '* and not kvm*')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200143
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +0100144}
Jakub Josef79ecec32017-02-17 14:36:28 +0100145
vrovachev1c4770b2017-07-05 13:25:21 +0400146def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +0100147 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100148 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200149
Jakub Josef79ecec32017-02-17 14:36:28 +0100150 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200151 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100152 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100153
Jakub Josef432e9d92018-02-06 18:28:37 +0100154 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100155 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100156 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200157 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200158
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300159 // Ensure glusterfs clusters is ready
160 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100161 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300162 }
163
Jakub Josef79ecec32017-02-17 14:36:28 +0100164 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200165 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100166 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100167 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400168
169 // Check galera status
170 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
171 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300172 // If galera is not enabled check if we need to install mysql:server
173 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100174 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300175 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100176 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300177 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200178 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100179 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200180
vrovachev1c4770b2017-07-05 13:25:21 +0400181 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200182 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400183 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200184 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400185 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200186
vrovachev1c4770b2017-07-05 13:25:21 +0400187 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200188 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100189 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
190 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400191 }
192
193 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200194 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100195 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400196
197 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100198 common.retry(3,5){
199 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
200 }
vrovachev1c4770b2017-07-05 13:25:21 +0400201 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200202
Jakub Josef79ecec32017-02-17 14:36:28 +0100203 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200204 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100205 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400206 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
207 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
208 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200209
Jakub Josef79ecec32017-02-17 14:36:28 +0100210 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200211 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100212 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400213 }
214
215 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200216 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400217 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100218 common.retry(3,5){
219 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
220 }
vrovachev1c4770b2017-07-05 13:25:21 +0400221 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200222
223 // Install redis
224 if (salt.testTarget(master, 'I@redis:server')) {
225 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
226 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
227 }
228 salt.enforceState(master, 'I@redis:server', 'redis')
229 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100230 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400231}
232
233def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100234 def common = new com.mirantis.mk.Common()
235 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
236 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100237}
238
239
Ales Komarekef2bab62017-04-26 11:48:28 +0200240def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100241 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100242 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200243
244 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300245 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100246 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300247 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100248 // Install sphinx server
249 if (salt.testTarget(master, 'I@sphinx:server')) {
250 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
251 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300252 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100253 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
254 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300255 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200256
Jakub Josef79ecec32017-02-17 14:36:28 +0100257 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300258 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100259 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
260 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300261 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100262
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300263 // keystone:client must be called locally
264 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
265 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
266 sleep(30)
267 }
268 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100269 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
270 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300271 }
272 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100273 common.retry(3,5){
274 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
275 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300276 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100277
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300278 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300279 if (salt.testTarget(master, 'I@glance:server')) {
280 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100281 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
282 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300283 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200284
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300285 // Check glance service
286 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100287 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200288 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100289 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300290 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200291
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400292 // Create glance resources
293 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100294 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400295 }
296
Jakub Josef79ecec32017-02-17 14:36:28 +0100297 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300298 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100299 // run on first node first
300 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
301 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300302 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100303 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200304 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100305 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300306 }
307 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200308
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400309 // Create nova resources
310 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100311 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400312 }
313
Jakub Josef79ecec32017-02-17 14:36:28 +0100314 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300315 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100316 // run on first node first
317 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
318 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300319 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100320 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200321 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100322 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300323 }
324 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200325
Jakub Josef79ecec32017-02-17 14:36:28 +0100326 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300327 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100328 // run on first node first
329 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
330 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300331 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100332 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200333 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100334 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300335 }
336 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200337
Jakub Josef79ecec32017-02-17 14:36:28 +0100338 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300339 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100340 // run on first node first
341 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
342 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300343 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100344 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200345 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100346 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300347 }
348 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200349
350 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300351 if (salt.testTarget(master, 'I@nova:controller')) {
352 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
353 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300354
355 // Install ironic service
356 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100357 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
358 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300359 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300360
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200361 // Install manila service
362 if (salt.testTarget(master, 'I@manila:api')) {
363 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
364 salt.enforceState(master, 'I@manila:api', 'manila.api')
365 }
366 if (salt.testTarget(master, 'I@manila:scheduler')) {
367 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
368 }
369
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200370 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300371 if (salt.testTarget(master, 'I@designate:server:enabled')) {
372 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100373 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300374 }
375 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100376 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300377 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100378 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200379 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300380 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400381
382 // Install octavia api service
383 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100384 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100385 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400386 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200387
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200388 // Install DogTag server service
389 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100390 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
391 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200392 }
393
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200394 // Install barbican server service
395 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100396 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
397 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200398 }
399 // Install barbican client
400 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100401 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200402 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100403
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200404 // Install gnocchi server
405 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200406 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200407 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
408 }
409
410 // Install gnocchi statsd
411 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200412 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200413 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
414 }
415
416 // Install panko server
417 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200418 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200419 salt.enforceState(master, 'I@panko:server', 'panko')
420 }
421
Ondrej Smola5908ae62018-01-08 13:42:08 +0100422 // Install ceilometer server
423 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200424 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100425 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100426 }
427
428 // Install aodh server
429 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200430 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100431 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100432 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100433}
434
435
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300436def installIronicConductor(master){
437 def salt = new com.mirantis.mk.Salt()
438
439 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100440 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
441 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300442 }
443 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100444 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300445 }
446
447 if (salt.testTarget(master, 'I@nova:compute')) {
448 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
449 }
450
451 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100452 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300453 }
454 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100455 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300456 }
457}
458
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200459def installManilaShare(master){
460 def salt = new com.mirantis.mk.Salt()
461
462 if (salt.testTarget(master, 'I@manila:share')) {
463 salt.enforceState(master, 'I@manila:share', 'manila.share')
464 }
465 if (salt.testTarget(master, 'I@manila:data')) {
466 salt.enforceState(master, 'I@manila:data', 'manila.data')
467 }
468
469 if (salt.testTarget(master, 'I@manila:client')) {
470 salt.enforceState(master, 'I@manila:client', 'manila.client')
471 }
472}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300473
474
Ales Komarekef2bab62017-04-26 11:48:28 +0200475def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100476 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300477 //run full neutron state on neutron.gateway - this will install
478 //neutron agents in addition to neutron server. Once neutron agents
479 //are up neutron resources can be created without hitting the situation when neutron resources are created
480 //prior to neutron agents which results in creating ports in non-usable state
481 if (salt.testTarget(master, 'I@neutron:gateway')) {
482 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
483 }
484
485 // Create neutron resources - this step was moved here to ensure that
486 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
487 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
488 if (salt.testTarget(master, 'I@neutron:client')) {
489 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
490 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200491
Jakub Josef432e9d92018-02-06 18:28:37 +0100492 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400493
494 // install octavia manager services
495 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100496 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
497 salt.enforceState(master, 'I@octavia:manager', 'octavia')
498 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
499 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400500 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200501}
502
503
504def installOpenstackCompute(master) {
505 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200506 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100507 def compute_compound = 'I@nova:compute'
508 if (salt.testTarget(master, compute_compound)) {
509 // In case if infrastructure nodes are used as nova computes too
510 def gluster_compound = 'I@glusterfs:server'
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200511 def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca'
512 // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers
Oleh Hryhorov73f9fa22018-05-02 17:36:58 +0300513 def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}"
514 if (salt.testTarget(master, hightstateTarget)) {
515 retry(2) {
516 salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client')
517 }
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200518 }
519 // Iterate through salt ca servers and check if they have compute role
520 // TODO: switch to batch once salt 2017.7+ would be used
521 for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) {
522 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
523 if ( target == cmp_target ) {
524 // Enforce highstate one by one on salt ca servers which are compute nodes
525 retry(2) {
526 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
527 }
528 }
529 }
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100530 }
531 // Iterate through glusterfs servers and check if they have compute role
532 // TODO: switch to batch once salt 2017.7+ would be used
533 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
534 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
535 if ( target == cmp_target ) {
536 // Enforce highstate one by one on glusterfs servers which are compute nodes
537 retry(2) {
538 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
539 }
540 }
541 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200542 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200543 }
544}
545
546
547def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200548 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200549 def salt = new com.mirantis.mk.Salt()
550
551
Jakub Josef79ecec32017-02-17 14:36:28 +0100552 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100553 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
554 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200555
Jakub Josef79ecec32017-02-17 14:36:28 +0100556 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100557 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
558 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
559 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100560
Marek Celoud443fb642017-11-22 15:07:12 +0100561 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100562 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100563 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100564 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100565}
566
567
Ales Komarekef2bab62017-04-26 11:48:28 +0200568def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200569 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400570 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100571 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200572 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100573 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100574 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100575
vrovachev4ff77302017-08-09 20:39:57 +0400576 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200577 if (salt.testTarget(master, 'I@opencontrail:compute')) {
578 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
579 }
vrovachev4ff77302017-08-09 20:39:57 +0400580
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200581 if (salt.testTarget(master, 'I@nova:compute')) {
582 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)
583 }
vrovachev4ff77302017-08-09 20:39:57 +0400584
Jakub Josef61463c72018-02-13 16:10:56 +0100585 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400586 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100587 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
588 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400589 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100590}
591
592
Ales Komarekef2bab62017-04-26 11:48:28 +0200593def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100594 def common = new com.mirantis.mk.Common()
595 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
596 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100597}
598
599
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200600def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100601 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200602
Jakub Josef79ecec32017-02-17 14:36:28 +0100603 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200604 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
605 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100606
Marek Celoud029391c2017-11-14 10:06:18 +0100607 if (salt.testTarget(master, 'I@etcd:server:setup')) {
608 // Setup etcd server
609 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
610 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100611
612 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100613 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100614
615 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200616 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100617
618 // Restart kubelet
619 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
620}
621
622
Ales Komarekef2bab62017-04-26 11:48:28 +0200623def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200624 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100625 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200626
627 // Bootstrap all nodes
628 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
629 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
630 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
631
632 // Create and distribute SSL certificates for services using salt state
633 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
634
635 // Install docker
636 salt.enforceState(master, 'I@docker:host', 'docker.host')
637
638 // Install Kubernetes and Calico
639 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
640
Yuriy Taradayab564d72017-10-11 15:14:35 +0400641 // Install Tiller and all configured releases
642 if (salt.testTarget(master, 'I@helm:client')) {
643 salt.enforceState(master, 'I@helm:client', 'helm')
644 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200645}
646
647
Martin Polreich8663a342017-06-30 17:33:08 +0200648def installDockerSwarm(master) {
649 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100650
vrovachev1c4770b2017-07-05 13:25:21 +0400651 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200652 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100653 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
654 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
655 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
656 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200657 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100658 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
659 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100660 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100661 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200662}
663
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200664
665def installCicd(master) {
666 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100667 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100668
Richard Felklc1aba9b2018-01-02 09:25:20 +0100669 if (salt.testTarget(master, 'I@aptly:publisher')) {
670 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
671 }
672
Richard Felkl6de16762017-11-20 11:42:28 +0100673 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 +0200674 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100675
676 if (salt.testTarget(master, 'I@aptly:server')) {
677 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
678 }
679
680 if (salt.testTarget(master, 'I@openldap:client')) {
681 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
682 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200683
684 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100685 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200686 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100687
Richard Felkl6e208fc2017-12-08 10:18:44 +0100688 withEnv(['ASK_ON_ERROR=false']){
689 retry(2){
690 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100691 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100692 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100693 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100694 throw e //rethrow for retry handler
695 }
696 }
697 retry(2){
698 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100699 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100700 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100701 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100702 throw e //rethrow for retry handler
703 }
704 }
705 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200706}
707
708
Martin Polreich8663a342017-06-30 17:33:08 +0200709def installStacklight(master) {
710 def common = new com.mirantis.mk.Common()
711 def salt = new com.mirantis.mk.Salt()
712
Simon Pasquieref4122c2017-08-25 15:52:07 +0200713 // Install core services for K8S environments:
714 // HAProxy, Nginx and lusterFS clients
715 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200716 if (common.checkContains('STACK_INSTALL', 'k8s')) {
717 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
718 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200719
720 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100721 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200722 }
723
724 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100725 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200726 }
Martin Polreich792f2662017-07-11 13:36:32 +0200727 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200728
729 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100730 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
731 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200732
Martin Polreich8663a342017-06-30 17:33:08 +0200733 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100734 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200735
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400736 // Install Prometheus exporters
737 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100738 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400739 }
740
Martin Polreich8663a342017-06-30 17:33:08 +0200741 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100742 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
743 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
744 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
745 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
746 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
747 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400748
749 //Install InfluxDB
750 if (salt.testTarget(master, 'I@influxdb:server')) {
751 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
752 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
753 }
754
755 //Install Prometheus LTS
756 if (salt.testTarget(master, 'I@prometheus:relay')) {
757 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
758 }
Martin Polreich8663a342017-06-30 17:33:08 +0200759
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400760 // Install service for the log collection
761 if (salt.testTarget(master, 'I@fluentd:agent')) {
762 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
763 } else {
764 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
765 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200766
Ondrej Smola5908ae62018-01-08 13:42:08 +0100767 // Install heka ceilometer collector
768 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100769 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100770 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
771 }
772
Martin Polreich470925a2017-07-06 17:12:59 +0200773 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200774 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100775 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100776 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000777
Martin Polreich792f2662017-07-11 13:36:32 +0200778 // Check galera status
779 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
780 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
781 }
Martin Polreich470925a2017-07-06 17:12:59 +0200782
Martin Polreich8663a342017-06-30 17:33:08 +0200783 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100784 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
785 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
786 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200787 sleep(5)
788
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400789 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100790 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400791
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400792 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400793 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400794 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200795 }
Martin Polreich8663a342017-06-30 17:33:08 +0200796
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100797 // Install sphinx server
798 if (salt.testTarget(master, 'I@sphinx:server')) {
799 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
800 }
801
Martin Polreich8663a342017-06-30 17:33:08 +0200802 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200803 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200804 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200805
Martin Polreich8663a342017-06-30 17:33:08 +0200806 def stacklight_vip
807 if(!pillar['return'].isEmpty()) {
808 stacklight_vip = pillar['return'][0].values()[0]
809 } else {
810 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
811 }
vrovachev1c4770b2017-07-05 13:25:21 +0400812
Martin Polreich305e2222017-07-06 11:33:00 +0200813 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200814 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100815 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200816}
817
818def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200819 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200820
821 // infra install
822 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100823 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
824 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200825
Jakub Josef432e9d92018-02-06 18:28:37 +0100826 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
827 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200828
Jakub Josef432e9d92018-02-06 18:28:37 +0100829 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
830 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200831
Jakub Josef432e9d92018-02-06 18:28:37 +0100832 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
833 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200834
Kalynovskyi3e370112017-06-26 12:48:23 +0300835 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
836 def alarming_service = alarming_service_pillar['return'][0].values()[0]
837
838 switch (alarming_service) {
839 case 'sensu':
840 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100841 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
842 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
843 salt.enforceState(master, 'I@redis:server', 'redis')
844 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300845 default:
846 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100847 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300848 // Stop the Nagios service because the package starts it by default and it will
849 // started later only on the node holding the VIP address
850 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
851 }
852
Jakub Josef432e9d92018-02-06 18:28:37 +0100853 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
854 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200855
856 sleep(10)
857}
858
Martin Polreich8663a342017-06-30 17:33:08 +0200859def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200860 def salt = new com.mirantis.mk.Salt()
861 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200862
Jakub Josef432e9d92018-02-06 18:28:37 +0100863 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200864 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100865 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200866 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
867
868 // Install collectd, heka and sensu services on the nodes, this will also
869 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100870 salt.enforceState(master, '*', 'collectd')
871 salt.enforceState(master, '*', 'salt.minion')
872 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200873
874 // Gather the Grafana metadata as grains
875 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
876
877 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100878 salt.enforceState(master, '*', 'salt.minion.grains')
879 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
880 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200881
882 sleep(5)
883
884 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100885 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200886
887 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100888 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200889
Kalynovskyi3e370112017-06-26 12:48:23 +0300890 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
891 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200892
Kalynovskyi3e370112017-06-26 12:48:23 +0300893 switch (alarming_service) {
894 case 'sensu':
895 // Update Sensu
896 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100897 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300898 default:
899 break
900 // Default is nagios, and was enforced in installStacklightControl()
901 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200902
Jakub Josef432e9d92018-02-06 18:28:37 +0100903 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200904 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
905
Marek Celoudd200cad2017-06-07 10:34:46 +0200906 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100907 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
908 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
909 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200910 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
911
Ales Komarekef2bab62017-04-26 11:48:28 +0200912 // Get the StackLight monitoring VIP addres
913 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
914 //vip=${vip:=172.16.10.253}
915 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200916 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200917 def stacklight_vip = pillar['return'][0].values()[0]
918
919 if (stacklight_vip) {
920 // (re)Start manually the services that are bound to the monitoring VIP
921 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100922 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
923 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
924 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
925 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200926 } else {
927 throw new Exception("Missing stacklight_vip")
928 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100929}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200930
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100931//
932// backups
933//
934
935def installBackup(master, component='common') {
936 def salt = new com.mirantis.mk.Salt()
937 if (component == 'common') {
938 // Install Backupninja
939 if (salt.testTarget(master, 'I@backupninja:client')) {
940 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
941 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100942 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100943 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100944 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100945 }
946 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100947 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100948 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100949 }
950 } else if (component == 'mysql') {
951 // Install Xtrabackup
952 if (salt.testTarget(master, 'I@xtrabackup:client')) {
953 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
954 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100955 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100956 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
957 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
958 }
959 if (salt.testTarget(master, 'I@xtrabackup:server')) {
960 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
961 }
962 } else if (component == 'contrail') {
963
964 // Install Cassandra backup
965 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
966 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
967 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100968 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100969 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
970 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
971 }
972 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
973 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
974 }
975 // Install Zookeeper backup
976 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
977 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
978 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100979 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100980 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
981 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
982 }
983 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
984 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
985 }
986 } else if (component == 'ceph') {
987 // Install Ceph backup
988 if (salt.testTarget(master, 'I@ceph:backup:client')) {
989 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
990 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100991 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100992 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100993 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100994 }
995 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100996 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100997 }
998 }
999
1000}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001001
1002//
1003// Ceph
1004//
1005
Tomáš Kukráled27a472017-08-29 10:26:25 +02001006def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001007 def salt = new com.mirantis.mk.Salt()
1008
Jakub Josef432e9d92018-02-06 18:28:37 +01001009 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +02001010
Jiri Broulike57a0242017-10-06 13:38:47 +02001011 // generate keyrings
1012 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001013 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
1014 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
1015 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +02001016 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +02001017 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +02001018 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +01001019 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +02001020 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001021 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +02001022 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001023}
1024
Tomáš Kukráled27a472017-08-29 10:26:25 +02001025def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001026 def salt = new com.mirantis.mk.Salt()
1027
1028 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +01001029 salt.enforceState(master, target, 'ceph.osd')
1030 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1031 salt.enforceState(master, target, 'ceph.osd.custom')
1032 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1033 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001034 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001035
Jiri Broulike57a0242017-10-06 13:38:47 +02001036 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +02001037 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +02001038 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +01001039 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001040 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001041}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001042
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001043def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001044 def salt = new com.mirantis.mk.Salt()
1045
1046 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001047 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001048 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
1049 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +04001050 }
1051 // setup Keystone service and endpoints for swift or / and S3
1052 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001053 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001054 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001055}
Jiri Broulike57a0242017-10-06 13:38:47 +02001056
1057def connectCeph(master) {
1058 def salt = new com.mirantis.mk.Salt()
1059
1060 // connect Ceph to the env
1061 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001062 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001063 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
1064 }
1065 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001066 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001067 }
1068 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001069 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1070 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1071 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001072 }
1073}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001074
1075def installOssInfra(master) {
1076 def common = new com.mirantis.mk.Common()
1077 def salt = new com.mirantis.mk.Salt()
1078
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001079 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001080 def orchestrate = new com.mirantis.mk.Orchestrate()
1081 orchestrate.installInfra(master)
1082 }
1083
1084 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001085 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1086 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1087 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001088 }
1089}
1090
1091def installOss(master) {
1092 def common = new com.mirantis.mk.Common()
1093 def salt = new com.mirantis.mk.Salt()
1094
1095 //Get oss VIP address
1096 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1097 common.prettyPrint(pillar)
1098
1099 def oss_vip
1100 if(!pillar['return'].isEmpty()) {
1101 oss_vip = pillar['return'][0].values()[0]
1102 } else {
1103 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1104 }
1105
1106 // Postgres client - initialize OSS services databases
1107 timeout(120){
1108 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001109 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 +04001110 }
1111 // XXX: first run usually fails on some inserts, but we need to create databases at first
1112 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1113
1114 // Setup postgres database with integration between
1115 // Pushkin notification service and Security Monkey security audit service
1116 timeout(10) {
1117 common.infoMsg("Waiting for Pushkin to come up..")
1118 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1119 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001120 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001121
1122 // Rundeck
1123 timeout(10) {
1124 common.infoMsg("Waiting for Rundeck to come up..")
1125 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1126 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001127 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001128
1129 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001130 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1131 def elasticsearch_vip
1132 if(!pillar['return'].isEmpty()) {
1133 elasticsearch_vip = pillar['return'][0].values()[0]
1134 } else {
1135 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1136 }
1137
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001138 timeout(10) {
1139 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001140 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 +04001141 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001142 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001143}