blob: a5beb4d10d57089f074a981bc5bc27c0f6b78589 [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2/**
3 * Orchestration functions
4 *
5*/
6
7def validateFoundationInfra(master) {
8 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +02009
Jakub Josef432e9d92018-02-06 18:28:37 +010010 salt.cmdRun(master, 'I@salt:master' ,'salt-key')
11 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version')
12 salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top')
13 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory')
14 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top')
Jakub Josef79ecec32017-02-17 14:36:28 +010015}
16
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010017def installFoundationInfra(master, staticMgmtNet=false) {
Jakub Josef79ecec32017-02-17 14:36:28 +010018 def salt = new com.mirantis.mk.Salt()
Jiri Broulik037f8982018-04-23 17:07:16 +020019 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +020020
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020021 // NOTE(vsaienko) Apply reclass first, it may update cluster model
22 // apply linux and salt.master salt.minion states afterwards to make sure
23 // correct cluster model is used.
Jakub Josef432e9d92018-02-06 18:28:37 +010024 salt.enforceState(master, 'I@salt:master', ['reclass'])
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020025
Jakub Josef432e9d92018-02-06 18:28:37 +010026 salt.enforceState(master, 'I@salt:master', ['linux.system'])
Vasyl Saienko0869b3a2017-11-22 14:37:57 +020027 salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010028 salt.fullRefresh(master, "*")
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020029
Vasyl Saienkoe36ab7c2017-07-17 14:35:48 +030030 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010031 salt.enforceState(master, 'I@salt:master', ['salt.minion'])
32 salt.fullRefresh(master, "*")
Ondrej Smolaa9b84662018-04-18 11:22:19 +020033 salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020034 try {
35 salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2)
36 sleep(5)
37 } catch (Throwable e) {
38 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
39 }
Jakub Josef432e9d92018-02-06 18:28:37 +010040 salt.enforceState(master, '*', ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010041 if (staticMgmtNet) {
42 salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
43 }
Jiri Broulik3740fb92018-04-27 11:52:38 +020044 salt.enforceState(master, 'I@linux:network:interface', ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010045 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog'])
Tomáš Kukrál7e767f92017-08-18 14:53:17 +020046 salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef4f8f4df2017-09-01 14:32:42 +020047 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040048 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010049 salt.enforceState(master, '*', ['linux.network.host'])
Ivan Suzdal9a6bc392018-04-26 18:29:56 +040050
51 // Install and configure iptables
52 if (salt.testTarget(master, 'I@iptables:service')) {
53 salt.enforceState(master, 'I@iptables:service', 'iptables')
54 }
sgarbuzbb61e812018-05-03 16:58:40 +030055
56 // Install and configure logrotate
57 if (salt.testTarget(master, 'I@logrotate:server')) {
58 salt.enforceState(master, 'I@logrotate:server', 'logrotate')
59 }
Jakub Josef79ecec32017-02-17 14:36:28 +010060}
61
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010062def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) {
Jiri Broulik976bf6c2017-10-20 14:43:25 +020063 def salt = new com.mirantis.mk.Salt()
Jiri Broulik9fb138a2018-04-23 17:13:00 +020064 def common = new com.mirantis.mk.Common()
Jiri Broulik976bf6c2017-10-20 14:43:25 +020065
66 salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010067 salt.fullRefresh(master, target)
Ondrej Smolaa9b84662018-04-18 11:22:19 +020068 salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2)
Jiri Broulik94fc2592018-04-20 13:47:51 +020069 try {
70 salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2)
71 sleep(5)
72 } catch (Throwable e) {
73 common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.')
74 }
Jakub Josef432e9d92018-02-06 18:28:37 +010075 salt.enforceState(master, target, ['linux.system'])
Jiri Broulik8e1f1fe2017-12-13 11:54:06 +010076 if (staticMgmtNet) {
77 salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60)
78 }
Jiri Broulik976bf6c2017-10-20 14:43:25 +020079 salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2)
Jakub Josef432e9d92018-02-06 18:28:37 +010080 salt.enforceState(master, target, ['salt.minion'])
Jiri Broulik3740fb92018-04-27 11:52:38 +020081 salt.enforceState(master, target, ['linux.network.interface'])
Jiri Broulike3e7bc32018-02-26 10:50:07 +010082 salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020083 sleep(5)
vrovachevc4424a32018-03-15 17:35:57 +040084 salt.runSaltProcessStep(master, target, 'mine.update', [], null, true)
Jakub Josef432e9d92018-02-06 18:28:37 +010085 salt.enforceState(master, target, ['linux.network.host'])
Jiri Broulik976bf6c2017-10-20 14:43:25 +020086}
87
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010088def installInfraKvm(master) {
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020089 def common = new com.mirantis.mk.Common()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010090 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +010091 salt.fullRefresh(master, 'I@linux:system')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +020092 def infra_conpund = 'I@salt:control'
93 def minions = []
94 def wait_timeout = 10
95 def retries = wait_timeout * 30
Ales Komarekef2bab62017-04-26 11:48:28 +020096
Richard Felkl286f25f2017-07-26 14:23:55 +020097 salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2)
Jiri Broulike3e7bc32018-02-26 10:50:07 +010098 salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog'])
Jakub Josef432e9d92018-02-06 18:28:37 +010099 salt.enforceState(master, 'I@salt:control', 'libvirt')
100 salt.enforceState(master, 'I@salt:control', 'salt.control')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100101
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200102 timeout(wait_timeout) {
103 common.infoMsg("Waiting for minions to come up...")
104 if (salt.testTarget(master, infra_conpund)) {
105 // Gathering minions
106 for ( infra_node in salt.getMinionsSorted(master, infra_conpund) ) {
107 def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster')
108 if ( !pillar['return'].isEmpty() ) {
109 for ( cluster in pillar['return'][0].values() ) {
110 def engine = cluster.values()[0]['engine']
111 def domain = cluster.values()[0]['domain']
112 def node = cluster.values()[0]['node']
113 if ( engine == "virt" ) {
114 def nodes = node.values()
115 if ( !nodes.isEmpty() ) {
116 for ( vm in nodes ) {
117 if ( vm['name'] != null ) {
118 def vm_fqdn = vm['name'] + '.' + domain
119 if ( !minions.contains(vm_fqdn) ) {
120 minions.add(vm_fqdn)
121 }
122 }
123 }
124 }
125 }
126 }
127 }
128 }
129 }
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100130
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200131 def minions_compound = minions.join(' or ')
132 common.infoMsg('Waiting for next minions to register: ' + minions_compound,)
133 salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1)
134 common.infoMsg('Waiting for minions to respond')
135 salt.minionsReachable(master, 'I@salt:master', minions_compound )
136
137 }
138
139 common.infoMsg("All minions are up.")
Jakub Josef432e9d92018-02-06 18:28:37 +0100140 salt.fullRefresh(master, '* and not kvm*')
Dzmitry Stremkouski8a8d56b2018-05-01 12:20:04 +0200141
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +0100142}
Jakub Josef79ecec32017-02-17 14:36:28 +0100143
vrovachev1c4770b2017-07-05 13:25:21 +0400144def installInfra(master) {
Jakub Josef61463c72018-02-13 16:10:56 +0100145 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100146 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200147
Jakub Josef79ecec32017-02-17 14:36:28 +0100148 // Install glusterfs
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200149 if (salt.testTarget(master, 'I@glusterfs:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100150 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100151
Jakub Josef432e9d92018-02-06 18:28:37 +0100152 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5)
Jakub Josef61463c72018-02-13 16:10:56 +0100153 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100154 salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status")
Alexander Noskov93acac42017-06-20 17:55:55 +0200155 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200156
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300157 // Ensure glusterfs clusters is ready
158 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100159 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300160 }
161
Jakub Josef79ecec32017-02-17 14:36:28 +0100162 // Install galera
Richard Felklc0f163e2017-07-27 15:11:12 +0200163 if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100164 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100165 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400166
167 // Check galera status
168 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
169 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300170 // If galera is not enabled check if we need to install mysql:server
171 } else if (salt.testTarget(master, 'I@mysql:server')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100172 salt.enforceState(master, 'I@mysql:server', 'mysql.server')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300173 if (salt.testTarget(master, 'I@mysql:client')){
Jakub Josef432e9d92018-02-06 18:28:37 +0100174 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
Vasyl Saienkoc1fb9892017-07-13 14:54:13 +0300175 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200176 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100177 installBackup(master, 'mysql')
Ales Komarekef2bab62017-04-26 11:48:28 +0200178
vrovachev1c4770b2017-07-05 13:25:21 +0400179 // Install docker
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200180 if (salt.testTarget(master, 'I@docker:host')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400181 salt.enforceState(master, 'I@docker:host', 'docker.host')
Tomáš Kukrál0cf3ffb2017-09-03 10:18:18 +0200182 salt.cmdRun(master, 'I@docker:host', 'docker ps')
vrovachev1c4770b2017-07-05 13:25:21 +0400183 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200184
vrovachev1c4770b2017-07-05 13:25:21 +0400185 // Install keepalived
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200186 if (salt.testTarget(master, 'I@keepalived:cluster')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100187 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
188 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
vrovachev1c4770b2017-07-05 13:25:21 +0400189 }
190
191 // Install rabbitmq
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200192 if (salt.testTarget(master, 'I@rabbitmq:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100193 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2)
vrovachev1c4770b2017-07-05 13:25:21 +0400194
195 // Check the rabbitmq status
Jakub Josef61463c72018-02-13 16:10:56 +0100196 common.retry(3,5){
197 salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status')
198 }
vrovachev1c4770b2017-07-05 13:25:21 +0400199 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200200
Jakub Josef79ecec32017-02-17 14:36:28 +0100201 // Install haproxy
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200202 if (salt.testTarget(master, 'I@haproxy:proxy')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100203 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
vrovachev1c4770b2017-07-05 13:25:21 +0400204 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
205 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
206 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200207
Jakub Josef79ecec32017-02-17 14:36:28 +0100208 // Install memcached
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200209 if (salt.testTarget(master, 'I@memcached:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100210 salt.enforceState(master, 'I@memcached:server', 'memcached')
vrovachev1c4770b2017-07-05 13:25:21 +0400211 }
212
213 // Install etcd
Tomáš Kukráld0cf7ec2017-07-13 11:29:20 +0200214 if (salt.testTarget(master, 'I@etcd:server')) {
vrovachev1c4770b2017-07-05 13:25:21 +0400215 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Jakub Josef61463c72018-02-13 16:10:56 +0100216 common.retry(3,5){
217 salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health')
218 }
vrovachev1c4770b2017-07-05 13:25:21 +0400219 }
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200220
221 // Install redis
222 if (salt.testTarget(master, 'I@redis:server')) {
223 if (salt.testTarget(master, 'I@redis:cluster:role:master')) {
224 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
225 }
226 salt.enforceState(master, 'I@redis:server', 'redis')
227 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100228 installBackup(master, 'common')
vrovachev1c4770b2017-07-05 13:25:21 +0400229}
230
231def installOpenstackInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100232 def common = new com.mirantis.mk.Common()
233 common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly")
234 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100235}
236
237
Ales Komarekef2bab62017-04-26 11:48:28 +0200238def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100239 def salt = new com.mirantis.mk.Salt()
Jakub Josef61463c72018-02-13 16:10:56 +0100240 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200241
242 // Install horizon dashboard
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300243 if (salt.testTarget(master, 'I@horizon:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100244 salt.enforceState(master, 'I@horizon:server', 'horizon')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300245 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100246 // Install sphinx server
247 if (salt.testTarget(master, 'I@sphinx:server')) {
248 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
249 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300250 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100251 salt.enforceState(master, 'I@nginx:server', 'salt.minion')
252 salt.enforceState(master, 'I@nginx:server', 'nginx')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300253 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200254
Jakub Josef79ecec32017-02-17 14:36:28 +0100255 // setup keystone service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300256 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100257 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server')
258 salt.enforceState(master, 'I@keystone:server', 'keystone.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300259 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100260
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300261 // keystone:client must be called locally
262 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
263 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
264 sleep(30)
265 }
266 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100267 salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client')
268 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300269 }
270 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100271 common.retry(3,5){
272 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list')
273 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300274 }
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100275
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300276 // Install glance
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300277 if (salt.testTarget(master, 'I@glance:server')) {
278 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Jakub Josef432e9d92018-02-06 18:28:37 +0100279 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server')
280 salt.enforceState(master, 'I@glance:server', 'glance.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300281 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200282
Oleg Grigorov26c8a6c2017-08-17 18:54:02 +0300283 // Check glance service
284 if (salt.testTarget(master, 'I@glance:server')){
Jakub Josef61463c72018-02-13 16:10:56 +0100285 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200286 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100287 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300288 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200289
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400290 // Create glance resources
291 if (salt.testTarget(master, 'I@glance:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100292 salt.enforceState(master, 'I@glance:client', 'glance.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400293 }
294
Jakub Josef79ecec32017-02-17 14:36:28 +0100295 // Install and check nova service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300296 if (salt.testTarget(master, 'I@nova:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100297 // run on first node first
298 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller')
299 salt.enforceState(master, 'I@nova:controller', 'nova.controller')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300300 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100301 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200302 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100303 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300304 }
305 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200306
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400307 // Create nova resources
308 if (salt.testTarget(master, 'I@nova:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100309 salt.enforceState(master, 'I@nova:client', 'nova.client')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400310 }
311
Jakub Josef79ecec32017-02-17 14:36:28 +0100312 // Install and check cinder service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300313 if (salt.testTarget(master, 'I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100314 // run on first node first
315 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder')
316 salt.enforceState(master, 'I@cinder:controller', 'cinder')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300317 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100318 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200319 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list')
Jakub Josef61463c72018-02-13 16:10:56 +0100320 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300321 }
322 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200323
Jakub Josef79ecec32017-02-17 14:36:28 +0100324 // Install neutron service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300325 if (salt.testTarget(master, 'I@neutron:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100326 // run on first node first
327 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server')
328 salt.enforceState(master, 'I@neutron:server', 'neutron.server')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300329 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100330 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200331 salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100332 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300333 }
334 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200335
Jakub Josef79ecec32017-02-17 14:36:28 +0100336 // Install heat service
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300337 if (salt.testTarget(master, 'I@heat:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100338 // run on first node first
339 salt.enforceState(master, 'I@heat:server and *01*', 'heat')
340 salt.enforceState(master, 'I@heat:server', 'heat')
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300341 if (salt.testTarget(master, 'I@keystone:server')) {
Jakub Josef61463c72018-02-13 16:10:56 +0100342 common.retry(3,5){
Oleg Iurchenko01410f22018-02-22 22:18:21 +0200343 salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list')
Jakub Josef61463c72018-02-13 16:10:56 +0100344 }
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300345 }
346 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200347
348 // Restart nova api
Vasyl Saienko962e0b52017-07-11 10:49:19 +0300349 if (salt.testTarget(master, 'I@nova:controller')) {
350 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
351 }
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300352
353 // Install ironic service
354 if (salt.testTarget(master, 'I@ironic:api')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100355 salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api')
356 salt.enforceState(master, 'I@ironic:api', 'ironic.api')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300357 }
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300358
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200359 // Install manila service
360 if (salt.testTarget(master, 'I@manila:api')) {
361 salt.enforceState(master, 'I@manila:api and *01*', 'manila.api')
362 salt.enforceState(master, 'I@manila:api', 'manila.api')
363 }
364 if (salt.testTarget(master, 'I@manila:scheduler')) {
365 salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler')
366 }
367
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200368 // Install designate services
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300369 if (salt.testTarget(master, 'I@designate:server:enabled')) {
370 if (salt.testTarget(master, 'I@designate:server:backend:bind9')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100371 salt.enforceState(master, 'I@bind:server', 'bind.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300372 }
373 if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100374 salt.enforceState(master, 'I@powerdns:server', 'powerdns.server')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300375 }
Jakub Josef432e9d92018-02-06 18:28:37 +0100376 salt.enforceState(master, 'I@designate:server and *01*', 'designate.server')
Oleh Hryhorova070fd02018-03-15 14:47:52 +0200377 salt.enforceState(master, 'I@designate:server', 'designate')
Andrey Shestakov82c0b892017-07-24 18:46:21 +0300378 }
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400379
380 // Install octavia api service
381 if (salt.testTarget(master, 'I@octavia:api')) {
Marcin Iwinskib1ac98e2018-02-08 10:16:49 +0100382 salt.enforceState(master, 'I@octavia:api and *01*', 'octavia')
Jakub Josef432e9d92018-02-06 18:28:37 +0100383 salt.enforceState(master, 'I@octavia:api', 'octavia')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400384 }
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200385
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200386 // Install DogTag server service
387 if (salt.testTarget(master, 'I@dogtag:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100388 salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server')
389 salt.enforceState(master, 'I@dogtag:server', 'dogtag.server')
Oleg Iurchenkod0898c92017-12-14 14:28:44 +0200390 }
391
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200392 // Install barbican server service
393 if (salt.testTarget(master, 'I@barbican:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100394 salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server')
395 salt.enforceState(master, 'I@barbican:server', 'barbican.server')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200396 }
397 // Install barbican client
398 if (salt.testTarget(master, 'I@barbican:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100399 salt.enforceState(master, 'I@barbican:client', 'barbican.client')
Marek Celoudc9dd50f2017-08-28 13:54:40 +0200400 }
Ondrej Smola5908ae62018-01-08 13:42:08 +0100401
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200402 // Install gnocchi server
403 if (salt.testTarget(master, 'I@gnocchi:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200404 salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200405 salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server')
406 }
407
408 // Install gnocchi statsd
409 if (salt.testTarget(master, 'I@gnocchi:statsd')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200410 salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200411 salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd')
412 }
413
414 // Install panko server
415 if (salt.testTarget(master, 'I@panko:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200416 salt.enforceState(master, 'I@panko:server and *01*', 'panko')
Mykyta Karpin8185e4a2018-02-23 19:15:48 +0200417 salt.enforceState(master, 'I@panko:server', 'panko')
418 }
419
Ondrej Smola5908ae62018-01-08 13:42:08 +0100420 // Install ceilometer server
421 if (salt.testTarget(master, 'I@ceilometer:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200422 salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer')
Jakub Josef432e9d92018-02-06 18:28:37 +0100423 salt.enforceState(master, 'I@ceilometer:server', 'ceilometer')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100424 }
425
426 // Install aodh server
427 if (salt.testTarget(master, 'I@aodh:server')) {
Mykyta Karpinf60f02f2018-03-14 19:24:51 +0200428 salt.enforceState(master, 'I@aodh:server and *01*', 'aodh')
Jakub Josef432e9d92018-02-06 18:28:37 +0100429 salt.enforceState(master, 'I@aodh:server', 'aodh')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100430 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100431}
432
433
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300434def installIronicConductor(master){
435 def salt = new com.mirantis.mk.Salt()
436
437 if (salt.testTarget(master, 'I@ironic:conductor')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100438 salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor')
439 salt.enforceState(master, 'I@ironic:conductor', 'apache')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300440 }
441 if (salt.testTarget(master, 'I@tftpd_hpa:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100442 salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300443 }
444
445 if (salt.testTarget(master, 'I@nova:compute')) {
446 salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute'])
447 }
448
449 if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100450 salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300451 }
452 if (salt.testTarget(master, 'I@ironic:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100453 salt.enforceState(master, 'I@ironic:client', 'ironic.client')
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300454 }
455}
456
Vasyl Saienkob7e4cdf2018-02-21 18:33:17 +0200457def installManilaShare(master){
458 def salt = new com.mirantis.mk.Salt()
459
460 if (salt.testTarget(master, 'I@manila:share')) {
461 salt.enforceState(master, 'I@manila:share', 'manila.share')
462 }
463 if (salt.testTarget(master, 'I@manila:data')) {
464 salt.enforceState(master, 'I@manila:data', 'manila.data')
465 }
466
467 if (salt.testTarget(master, 'I@manila:client')) {
468 salt.enforceState(master, 'I@manila:client', 'manila.client')
469 }
470}
Vasyl Saienkoa7c10c02017-07-13 10:43:43 +0300471
472
Ales Komarekef2bab62017-04-26 11:48:28 +0200473def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100474 def salt = new com.mirantis.mk.Salt()
Oleksii Grudevc4a485e2018-04-20 14:25:03 +0300475 //run full neutron state on neutron.gateway - this will install
476 //neutron agents in addition to neutron server. Once neutron agents
477 //are up neutron resources can be created without hitting the situation when neutron resources are created
478 //prior to neutron agents which results in creating ports in non-usable state
479 if (salt.testTarget(master, 'I@neutron:gateway')) {
480 salt.enforceState(master, 'I@neutron:gateway', 'neutron')
481 }
482
483 // Create neutron resources - this step was moved here to ensure that
484 //neutron resources are created after neutron agens are up. In this case neutron ports will be in
485 //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249
486 if (salt.testTarget(master, 'I@neutron:client')) {
487 salt.enforceState(master, 'I@neutron:client', 'neutron.client')
488 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200489
Jakub Josef432e9d92018-02-06 18:28:37 +0100490 salt.enforceHighstate(master, 'I@neutron:gateway')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400491
492 // install octavia manager services
493 if (salt.testTarget(master, 'I@octavia:manager')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100494 salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'])
495 salt.enforceState(master, 'I@octavia:manager', 'octavia')
496 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca')
497 salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert')
Elena Ezhova8d53bff2017-08-01 17:43:30 +0400498 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200499}
500
501
502def installOpenstackCompute(master) {
503 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200504 // Configure compute nodes
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100505 def compute_compound = 'I@nova:compute'
506 if (salt.testTarget(master, compute_compound)) {
507 // In case if infrastructure nodes are used as nova computes too
508 def gluster_compound = 'I@glusterfs:server'
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200509 def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca'
510 // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers
Oleh Hryhorov73f9fa22018-05-02 17:36:58 +0300511 def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}"
512 if (salt.testTarget(master, hightstateTarget)) {
513 retry(2) {
514 salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client')
515 }
Dzmitry Stremkouski7eca99d2018-04-25 18:44:26 +0200516 }
517 // Iterate through salt ca servers and check if they have compute role
518 // TODO: switch to batch once salt 2017.7+ would be used
519 for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) {
520 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
521 if ( target == cmp_target ) {
522 // Enforce highstate one by one on salt ca servers which are compute nodes
523 retry(2) {
524 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
525 }
526 }
527 }
Dzmitry Stremkouskifeb8ce92018-03-21 18:03:28 +0100528 }
529 // Iterate through glusterfs servers and check if they have compute role
530 // TODO: switch to batch once salt 2017.7+ would be used
531 for ( target in salt.getMinionsSorted(master, gluster_compound) ) {
532 for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) {
533 if ( target == cmp_target ) {
534 // Enforce highstate one by one on glusterfs servers which are compute nodes
535 retry(2) {
536 salt.enforceHighstateWithExclude(master, target, 'opencontrail.client')
537 }
538 }
539 }
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200540 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200541 }
542}
543
544
545def installContrailNetwork(master) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200546 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200547 def salt = new com.mirantis.mk.Salt()
548
549
Jakub Josef79ecec32017-02-17 14:36:28 +0100550 // Install opencontrail database services
Jakub Josef432e9d92018-02-06 18:28:37 +0100551 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database')
552 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database')
Ales Komarekef2bab62017-04-26 11:48:28 +0200553
Jakub Josef79ecec32017-02-17 14:36:28 +0100554 // Install opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100555 salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client")
556 salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client")
557 salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client")
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100558
Marek Celoud443fb642017-11-22 15:07:12 +0100559 if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100560 salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client')
Marek Celoud443fb642017-11-22 15:07:12 +0100561 }
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100562 installBackup(master, 'contrail')
Jakub Josef79ecec32017-02-17 14:36:28 +0100563}
564
565
Ales Komarekef2bab62017-04-26 11:48:28 +0200566def installContrailCompute(master) {
Tomáš Kukrál104a07a2017-07-13 12:19:11 +0200567 def salt = new com.mirantis.mk.Salt()
vrovachev32f7f542017-08-25 16:17:25 +0400568 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100569 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200570 // Provision opencontrail control services
Jakub Josef432e9d92018-02-06 18:28:37 +0100571 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client')
Jakub Josef79ecec32017-02-17 14:36:28 +0100572 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100573
vrovachev4ff77302017-08-09 20:39:57 +0400574 // Generate script /usr/lib/contrail/if-vhost0 for up vhost0
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200575 if (salt.testTarget(master, 'I@opencontrail:compute')) {
576 salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client")
577 }
vrovachev4ff77302017-08-09 20:39:57 +0400578
Sergio Lystopadcd5b2772018-02-09 14:37:10 +0200579 if (salt.testTarget(master, 'I@nova:compute')) {
580 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)
581 }
vrovachev4ff77302017-08-09 20:39:57 +0400582
Jakub Josef61463c72018-02-13 16:10:56 +0100583 sleep(300)
vrovachev4ff77302017-08-09 20:39:57 +0400584 if (salt.testTarget(master, 'I@opencontrail:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100585 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client')
586 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail')
vrovachev4ff77302017-08-09 20:39:57 +0400587 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100588}
589
590
Ales Komarekef2bab62017-04-26 11:48:28 +0200591def installKubernetesInfra(master) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100592 def common = new com.mirantis.mk.Common()
593 common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly")
594 installInfra(master)
Jakub Josef79ecec32017-02-17 14:36:28 +0100595}
596
597
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200598def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100599 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200600
Jakub Josef79ecec32017-02-17 14:36:28 +0100601 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200602 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
603 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100604
Marek Celoud029391c2017-11-14 10:06:18 +0100605 if (salt.testTarget(master, 'I@etcd:server:setup')) {
606 // Setup etcd server
607 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
608 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100609
610 // Run k8s without master.setup
Jakub Josef432e9d92018-02-06 18:28:37 +0100611 salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup")
Jakub Josef79ecec32017-02-17 14:36:28 +0100612
613 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200614 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100615
616 // Restart kubelet
617 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
618}
619
620
Ales Komarekef2bab62017-04-26 11:48:28 +0200621def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200622 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100623 salt.fullRefresh(master, "*")
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200624
625 // Bootstrap all nodes
626 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
627 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
628 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
629
630 // Create and distribute SSL certificates for services using salt state
631 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
632
633 // Install docker
634 salt.enforceState(master, 'I@docker:host', 'docker.host')
635
636 // Install Kubernetes and Calico
637 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
638
Yuriy Taradayab564d72017-10-11 15:14:35 +0400639 // Install Tiller and all configured releases
640 if (salt.testTarget(master, 'I@helm:client')) {
641 salt.enforceState(master, 'I@helm:client', 'helm')
642 }
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200643}
644
645
Martin Polreich8663a342017-06-30 17:33:08 +0200646def installDockerSwarm(master) {
647 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100648
vrovachev1c4770b2017-07-05 13:25:21 +0400649 //Install and Configure Docker
Martin Polreich8663a342017-06-30 17:33:08 +0200650 salt.enforceState(master, 'I@docker:swarm', 'docker.host')
Jakub Josef432e9d92018-02-06 18:28:37 +0100651 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
652 salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains')
653 salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update')
654 salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules')
Martin Polreich8663a342017-06-30 17:33:08 +0200655 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +0100656 salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm')
657 salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm')
Jakub Josef61463c72018-02-13 16:10:56 +0100658 sleep(10)
Jakub Josef432e9d92018-02-06 18:28:37 +0100659 salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls')
Martin Polreich8663a342017-06-30 17:33:08 +0200660}
661
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200662
663def installCicd(master) {
664 def salt = new com.mirantis.mk.Salt()
Jakub Josef432e9d92018-02-06 18:28:37 +0100665 salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client')
Richard Felkl9d2cd922017-11-03 11:49:32 +0100666
Richard Felklc1aba9b2018-01-02 09:25:20 +0100667 if (salt.testTarget(master, 'I@aptly:publisher')) {
668 salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2)
669 }
670
Richard Felkl6de16762017-11-20 11:42:28 +0100671 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 +0200672 sleep(500)
Richard Felklc1aba9b2018-01-02 09:25:20 +0100673
674 if (salt.testTarget(master, 'I@aptly:server')) {
675 salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2)
676 }
677
678 if (salt.testTarget(master, 'I@openldap:client')) {
679 salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2)
680 }
Richard Felklb6fdec92017-09-26 10:52:36 +0200681
682 if (salt.testTarget(master, 'I@python:environment')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100683 salt.enforceState(master, 'I@python:environment', 'python')
Richard Felklb6fdec92017-09-26 10:52:36 +0200684 }
Richard Felklc1aba9b2018-01-02 09:25:20 +0100685
Richard Felkl6e208fc2017-12-08 10:18:44 +0100686 withEnv(['ASK_ON_ERROR=false']){
687 retry(2){
688 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100689 salt.enforceState(master, 'I@gerrit:client', 'gerrit')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100690 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100691 salt.fullRefresh(master, 'I@gerrit:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100692 throw e //rethrow for retry handler
693 }
694 }
695 retry(2){
696 try{
Jakub Josef432e9d92018-02-06 18:28:37 +0100697 salt.enforceState(master, 'I@jenkins:client', 'jenkins')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100698 }catch(e){
Jakub Josef432e9d92018-02-06 18:28:37 +0100699 salt.fullRefresh(master, 'I@jenkins:client')
Richard Felkl6e208fc2017-12-08 10:18:44 +0100700 throw e //rethrow for retry handler
701 }
702 }
703 }
Jiri Broulikb9a0c592017-09-05 16:41:48 +0200704}
705
706
Martin Polreich8663a342017-06-30 17:33:08 +0200707def installStacklight(master) {
708 def common = new com.mirantis.mk.Common()
709 def salt = new com.mirantis.mk.Salt()
710
Simon Pasquieref4122c2017-08-25 15:52:07 +0200711 // Install core services for K8S environments:
712 // HAProxy, Nginx and lusterFS clients
713 // In case of OpenStack, those are already installed
Martin Polreich792f2662017-07-11 13:36:32 +0200714 if (common.checkContains('STACK_INSTALL', 'k8s')) {
715 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
716 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Simon Pasquieref4122c2017-08-25 15:52:07 +0200717
718 if (salt.testTarget(master, 'I@nginx:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100719 salt.enforceState(master, 'I@nginx:server', 'nginx')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200720 }
721
722 if (salt.testTarget(master, 'I@glusterfs:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100723 salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client')
Simon Pasquieref4122c2017-08-25 15:52:07 +0200724 }
Martin Polreich792f2662017-07-11 13:36:32 +0200725 }
Jiri Broulike57a0242017-10-06 13:38:47 +0200726
727 // Launch containers
Jakub Josef432e9d92018-02-06 18:28:37 +0100728 salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client')
729 salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps')
Jiri Broulike57a0242017-10-06 13:38:47 +0200730
Martin Polreich8663a342017-06-30 17:33:08 +0200731 //Install Telegraf
Jakub Josef432e9d92018-02-06 18:28:37 +0100732 salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf')
Martin Polreich8663a342017-06-30 17:33:08 +0200733
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400734 // Install Prometheus exporters
735 if (salt.testTarget(master, 'I@prometheus:exporters')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100736 salt.enforceState(master, 'I@prometheus:exporters', 'prometheus')
Dmitry Kalashnikebc1e1e2017-07-13 14:20:08 +0400737 }
738
Martin Polreich8663a342017-06-30 17:33:08 +0200739 //Install Elasticsearch and Kibana
Jakub Josef432e9d92018-02-06 18:28:37 +0100740 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
741 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
742 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
743 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
744 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
745 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Dmitry Kalashnik53feda72018-03-16 16:06:10 +0400746
747 //Install InfluxDB
748 if (salt.testTarget(master, 'I@influxdb:server')) {
749 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
750 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
751 }
752
753 //Install Prometheus LTS
754 if (salt.testTarget(master, 'I@prometheus:relay')) {
755 salt.enforceState(master, 'I@prometheus:relay', 'prometheus')
756 }
Martin Polreich8663a342017-06-30 17:33:08 +0200757
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400758 // Install service for the log collection
759 if (salt.testTarget(master, 'I@fluentd:agent')) {
760 salt.enforceState(master, 'I@fluentd:agent', 'fluentd')
761 } else {
762 salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector')
763 }
Simon Pasquier6301ddd2017-09-05 11:56:58 +0200764
Ondrej Smola5908ae62018-01-08 13:42:08 +0100765 // Install heka ceilometer collector
766 if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100767 salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector')
Ondrej Smola5908ae62018-01-08 13:42:08 +0100768 salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true)
769 }
770
Martin Polreich470925a2017-07-06 17:12:59 +0200771 // Install galera
Martin Polreich792f2662017-07-11 13:36:32 +0200772 if (common.checkContains('STACK_INSTALL', 'k8s')) {
Jakub Josef432e9d92018-02-06 18:28:37 +0100773 salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2)
Jakub Josef9994ea72018-03-05 13:23:07 +0100774 salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2)
Martin Polreich406f6462017-07-11 11:33:42 +0000775
Martin Polreich792f2662017-07-11 13:36:32 +0200776 // Check galera status
777 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
778 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
779 }
Martin Polreich470925a2017-07-06 17:12:59 +0200780
Martin Polreich8663a342017-06-30 17:33:08 +0200781 //Collect Grains
Jakub Josef432e9d92018-02-06 18:28:37 +0100782 salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains')
783 salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules')
784 salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update')
Martin Polreich8663a342017-06-30 17:33:08 +0200785 sleep(5)
786
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400787 // Configure Prometheus in Docker Swarm
Oleg Basov162dd8a2018-03-13 01:27:50 +0100788 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus')
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400789
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400790 //Configure Remote Collector in Docker Swarm for Openstack deployments
Ildar Svetlov794f89e2018-02-14 16:28:53 +0400791 if (!common.checkContains('STACK_INSTALL', 'k8s')) {
Ildar Svetlov0eec97d2018-02-15 10:06:40 +0400792 salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false)
Martin Polreich8017f452017-08-21 16:01:42 +0200793 }
Martin Polreich8663a342017-06-30 17:33:08 +0200794
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100795 // Install sphinx server
796 if (salt.testTarget(master, 'I@sphinx:server')) {
797 salt.enforceState(master, 'I@sphinx:server', 'sphinx')
798 }
799
Martin Polreich8663a342017-06-30 17:33:08 +0200800 //Configure Grafana
Martin Polreich305e2222017-07-06 11:33:00 +0200801 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Martin Polreich8663a342017-06-30 17:33:08 +0200802 common.prettyPrint(pillar)
Martin Polreich595baef2017-07-04 16:11:04 +0200803
Martin Polreich8663a342017-06-30 17:33:08 +0200804 def stacklight_vip
805 if(!pillar['return'].isEmpty()) {
806 stacklight_vip = pillar['return'][0].values()[0]
807 } else {
808 common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved')
809 }
vrovachev1c4770b2017-07-05 13:25:21 +0400810
Martin Polreich305e2222017-07-06 11:33:00 +0200811 common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start")
Martin Polreichbd7ad222017-07-06 12:53:51 +0200812 sleep(120)
Jakub Josef432e9d92018-02-06 18:28:37 +0100813 salt.enforceState(master, 'I@grafana:client', 'grafana.client')
Martin Polreich8663a342017-06-30 17:33:08 +0200814}
815
816def installStacklightv1Control(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200817 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200818
819 // infra install
820 // Install the StackLight backends
Jakub Josef432e9d92018-02-06 18:28:37 +0100821 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server')
822 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200823
Jakub Josef432e9d92018-02-06 18:28:37 +0100824 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb')
825 salt.enforceState(master, 'I@influxdb:server', 'influxdb')
Ales Komarekef2bab62017-04-26 11:48:28 +0200826
Jakub Josef432e9d92018-02-06 18:28:37 +0100827 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server')
828 salt.enforceState(master, 'I@kibana:server', 'kibana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200829
Jakub Josef432e9d92018-02-06 18:28:37 +0100830 salt.enforceState(master, '*01* and I@grafana:server','grafana.server')
831 salt.enforceState(master, 'I@grafana:server','grafana.server')
Ales Komarekef2bab62017-04-26 11:48:28 +0200832
Kalynovskyi3e370112017-06-26 12:48:23 +0300833 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
834 def alarming_service = alarming_service_pillar['return'][0].values()[0]
835
836 switch (alarming_service) {
837 case 'sensu':
838 // Update Sensu
Jakub Josef432e9d92018-02-06 18:28:37 +0100839 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq')
840 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis')
841 salt.enforceState(master, 'I@redis:server', 'redis')
842 salt.enforceState(master, 'I@sensu:server', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300843 default:
844 // Update Nagios
Jakub Josef432e9d92018-02-06 18:28:37 +0100845 salt.enforceState(master, 'I@nagios:server', 'nagios.server')
Kalynovskyi3e370112017-06-26 12:48:23 +0300846 // Stop the Nagios service because the package starts it by default and it will
847 // started later only on the node holding the VIP address
848 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
849 }
850
Jakub Josef432e9d92018-02-06 18:28:37 +0100851 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service')
852 salt.enforceState(master, 'I@kibana:client', 'kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200853
854 sleep(10)
855}
856
Martin Polreich8663a342017-06-30 17:33:08 +0200857def installStacklightv1Client(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200858 def salt = new com.mirantis.mk.Salt()
859 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200860
Jakub Josef432e9d92018-02-06 18:28:37 +0100861 salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200862 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Jakub Josef432e9d92018-02-06 18:28:37 +0100863 salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200864 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
865
866 // Install collectd, heka and sensu services on the nodes, this will also
867 // generate the metadata that goes into the grains and eventually into Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100868 salt.enforceState(master, '*', 'collectd')
869 salt.enforceState(master, '*', 'salt.minion')
870 salt.enforceState(master, '*', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200871
872 // Gather the Grafana metadata as grains
873 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
874
875 // Update Salt Mine
Jakub Josef432e9d92018-02-06 18:28:37 +0100876 salt.enforceState(master, '*', 'salt.minion.grains')
877 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules')
878 salt.runSaltProcessStep(master, '*', 'mine.update')
Ales Komarekef2bab62017-04-26 11:48:28 +0200879
880 sleep(5)
881
882 // Update Heka
Jakub Josef432e9d92018-02-06 18:28:37 +0100883 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka')
Ales Komarekef2bab62017-04-26 11:48:28 +0200884
885 // Update collectd
Jakub Josef432e9d92018-02-06 18:28:37 +0100886 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd')
Ales Komarekef2bab62017-04-26 11:48:28 +0200887
Kalynovskyi3e370112017-06-26 12:48:23 +0300888 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
889 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200890
Kalynovskyi3e370112017-06-26 12:48:23 +0300891 switch (alarming_service) {
892 case 'sensu':
893 // Update Sensu
894 // TODO for stacklight team, should be fixed in model
Jakub Josef432e9d92018-02-06 18:28:37 +0100895 salt.enforceState(master, 'I@sensu:client', 'sensu')
Kalynovskyi3e370112017-06-26 12:48:23 +0300896 default:
897 break
898 // Default is nagios, and was enforced in installStacklightControl()
899 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200900
Jakub Josef432e9d92018-02-06 18:28:37 +0100901 salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client')
Ales Komarekef2bab62017-04-26 11:48:28 +0200902 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
903
Marek Celoudd200cad2017-06-07 10:34:46 +0200904 // Finalize the configuration of Grafana (add the dashboards...)
Jakub Josef432e9d92018-02-06 18:28:37 +0100905 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client')
906 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client')
907 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client')
Marek Celoudd200cad2017-06-07 10:34:46 +0200908 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
909
Ales Komarekef2bab62017-04-26 11:48:28 +0200910 // Get the StackLight monitoring VIP addres
911 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
912 //vip=${vip:=172.16.10.253}
913 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200914 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200915 def stacklight_vip = pillar['return'][0].values()[0]
916
917 if (stacklight_vip) {
918 // (re)Start manually the services that are bound to the monitoring VIP
919 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
Jakub Josef432e9d92018-02-06 18:28:37 +0100920 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'])
921 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'])
922 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'])
923 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200924 } else {
925 throw new Exception("Missing stacklight_vip")
926 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100927}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200928
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100929//
930// backups
931//
932
933def installBackup(master, component='common') {
934 def salt = new com.mirantis.mk.Salt()
935 if (component == 'common') {
936 // Install Backupninja
937 if (salt.testTarget(master, 'I@backupninja:client')) {
938 salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains')
939 salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100940 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100941 salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100942 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100943 }
944 if (salt.testTarget(master, 'I@backupninja:server')) {
Jiri Broulik9e578da2018-03-01 13:15:53 +0100945 salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100946 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100947 }
948 } else if (component == 'mysql') {
949 // Install Xtrabackup
950 if (salt.testTarget(master, 'I@xtrabackup:client')) {
951 salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains')
952 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100953 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100954 salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update')
955 salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup')
956 }
957 if (salt.testTarget(master, 'I@xtrabackup:server')) {
958 salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup')
959 }
960 } else if (component == 'contrail') {
961
962 // Install Cassandra backup
963 if (salt.testTarget(master, 'I@cassandra:backup:client')) {
964 salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains')
965 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100966 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100967 salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update')
968 salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup')
969 }
970 if (salt.testTarget(master, 'I@cassandra:backup:server')) {
971 salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup')
972 }
973 // Install Zookeeper backup
974 if (salt.testTarget(master, 'I@zookeeper:backup:client')) {
975 salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains')
976 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100977 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100978 salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update')
979 salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup')
980 }
981 if (salt.testTarget(master, 'I@zookeeper:backup:server')) {
982 salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup')
983 }
984 } else if (component == 'ceph') {
985 // Install Ceph backup
986 if (salt.testTarget(master, 'I@ceph:backup:client')) {
987 salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains')
988 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains')
Jiri Broulik9e578da2018-03-01 13:15:53 +0100989 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100990 salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update')
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100991 salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100992 }
993 if (salt.testTarget(master, 'I@ceph:backup:server')) {
Jiri Broulikbe6898c2018-03-01 13:01:48 +0100994 salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup')
Jiri Broulike3e7bc32018-02-26 10:50:07 +0100995 }
996 }
997
998}
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +0200999
1000//
1001// Ceph
1002//
1003
Tomáš Kukráled27a472017-08-29 10:26:25 +02001004def installCephMon(master, target='I@ceph:mon') {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001005 def salt = new com.mirantis.mk.Salt()
1006
Jakub Josef432e9d92018-02-06 18:28:37 +01001007 salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains')
Jiri Broulikbfc234f2017-10-17 15:45:38 +02001008
Jiri Broulike57a0242017-10-06 13:38:47 +02001009 // generate keyrings
1010 if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001011 salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon')
1012 salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains')
1013 salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update')
Jiri Broulik3c75a6d2017-10-06 18:44:37 +02001014 sleep(5)
Jiri Broulike57a0242017-10-06 13:38:47 +02001015 }
Ondrej Smolafd5c2352017-08-11 14:25:39 +02001016 // install Ceph Mons
Jakub Josef432e9d92018-02-06 18:28:37 +01001017 salt.enforceState(master, target, 'ceph.mon')
Jiri Broulike57a0242017-10-06 13:38:47 +02001018 if (salt.testTarget(master, 'I@ceph:mgr')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001019 salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr')
Jiri Broulike57a0242017-10-06 13:38:47 +02001020 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001021}
1022
Tomáš Kukráled27a472017-08-29 10:26:25 +02001023def installCephOsd(master, target='I@ceph:osd', setup=true) {
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001024 def salt = new com.mirantis.mk.Salt()
1025
1026 // install Ceph OSDs
Jakub Josef432e9d92018-02-06 18:28:37 +01001027 salt.enforceState(master, target, 'ceph.osd')
1028 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1029 salt.enforceState(master, target, 'ceph.osd.custom')
1030 salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains')
1031 salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update')
Jiri Broulike3e7bc32018-02-26 10:50:07 +01001032 installBackup(master, 'ceph')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001033
Jiri Broulike57a0242017-10-06 13:38:47 +02001034 // setup pools, keyrings and maybe crush
Tomáš Kukráled27a472017-08-29 10:26:25 +02001035 if (salt.testTarget(master, 'I@ceph:setup') && setup) {
Jiri Broulik07f8de72017-10-09 14:12:17 +02001036 sleep(5)
Jakub Josef432e9d92018-02-06 18:28:37 +01001037 salt.enforceState(master, 'I@ceph:setup', 'ceph.setup')
Tomáš Kukráled27a472017-08-29 10:26:25 +02001038 }
Tomáš Kukrál64f8e1c2017-08-11 10:32:20 +02001039}
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001040
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001041def installCephClient(master) {
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001042 def salt = new com.mirantis.mk.Salt()
1043
1044 // install Ceph Radosgw
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001045 if (salt.testTarget(master, 'I@ceph:radosgw')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001046 salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains')
1047 salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw')
Alexander Noskov229035f2017-12-06 00:10:20 +04001048 }
1049 // setup Keystone service and endpoints for swift or / and S3
1050 if (salt.testTarget(master, 'I@keystone:client')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001051 salt.enforceState(master, 'I@keystone:client', 'keystone.client')
Tomáš Kukrál5836e3d2017-08-25 18:20:55 +02001052 }
Tomáš Kukrál1e5b2192017-08-15 16:58:18 +02001053}
Jiri Broulike57a0242017-10-06 13:38:47 +02001054
1055def connectCeph(master) {
1056 def salt = new com.mirantis.mk.Salt()
1057
1058 // connect Ceph to the env
1059 if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001060 salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001061 salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry'])
1062 }
1063 if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001064 salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001065 }
1066 if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001067 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'])
1068 salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains')
1069 salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'])
Jiri Broulike57a0242017-10-06 13:38:47 +02001070 }
1071}
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001072
1073def installOssInfra(master) {
1074 def common = new com.mirantis.mk.Common()
1075 def salt = new com.mirantis.mk.Salt()
1076
Mikhail Ivanov788996c2017-12-15 14:28:57 +04001077 if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) {
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001078 def orchestrate = new com.mirantis.mk.Orchestrate()
1079 orchestrate.installInfra(master)
1080 }
1081
1082 if (salt.testTarget(master, 'I@devops_portal:config')) {
Jakub Josef432e9d92018-02-06 18:28:37 +01001083 salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config')
1084 salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'])
1085 salt.enforceState(master, 'I@rundeck:server', 'rundeck.server')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001086 }
1087}
1088
1089def installOss(master) {
1090 def common = new com.mirantis.mk.Common()
1091 def salt = new com.mirantis.mk.Salt()
1092
1093 //Get oss VIP address
1094 def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address')
1095 common.prettyPrint(pillar)
1096
1097 def oss_vip
1098 if(!pillar['return'].isEmpty()) {
1099 oss_vip = pillar['return'][0].values()[0]
1100 } else {
1101 common.errorMsg('[ERROR] Oss VIP address could not be retrieved')
1102 }
1103
1104 // Postgres client - initialize OSS services databases
1105 timeout(120){
1106 common.infoMsg("Waiting for postgresql database to come up..")
Nikolas Britton4f62a092018-02-06 16:56:26 -06001107 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 +04001108 }
1109 // XXX: first run usually fails on some inserts, but we need to create databases at first
1110 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false)
1111
1112 // Setup postgres database with integration between
1113 // Pushkin notification service and Security Monkey security audit service
1114 timeout(10) {
1115 common.infoMsg("Waiting for Pushkin to come up..")
1116 salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done")
1117 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001118 salt.enforceState(master, 'I@postgresql:client', 'postgresql.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001119
1120 // Rundeck
1121 timeout(10) {
1122 common.infoMsg("Waiting for Rundeck to come up..")
1123 salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done")
1124 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001125 salt.enforceState(master, 'I@rundeck:client', 'rundeck.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001126
1127 // Elasticsearch
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001128 pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host')
1129 def elasticsearch_vip
1130 if(!pillar['return'].isEmpty()) {
1131 elasticsearch_vip = pillar['return'][0].values()[0]
1132 } else {
1133 common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved')
1134 }
1135
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001136 timeout(10) {
1137 common.infoMsg('Waiting for Elasticsearch to come up..')
Mikhail Ivanovfcd55d62017-12-19 16:51:35 +04001138 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 +04001139 }
Jakub Josef432e9d92018-02-06 18:28:37 +01001140 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client')
Mikhail Ivanov5312d1f2017-12-06 17:36:36 +04001141}