blob: fe939070c7538143c2bce7cfe5ddacf63146cb0f [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
10 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['salt-key'], null, true)
11 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version', [], null, true)
12 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true)
13 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory', [], null, true)
14 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top', [], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +010015}
16
17
18def installFoundationInfra(master) {
19 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020020
21 salt.enforceState(master, 'I@salt:master', ['salt.master', 'reclass'], true)
Ales Komarekef2bab62017-04-26 11:48:28 +020022 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
23 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
Marek Celoud3f552c62017-05-19 18:17:02 +020024 salt.enforceState(master, '*', 'linux.system.service', true)
Jakub Josef200550f2017-05-16 17:39:55 +020025 salt.enforceState(master, '*', ['linux.system'], true)
26 salt.enforceState(master, '*', ['salt.minion'], true)
Ales Komarekef2bab62017-04-26 11:48:28 +020027 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010028}
29
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010030def installInfraKvm(master) {
31 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010032
Ales Komarekef2bab62017-04-26 11:48:28 +020033 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
34 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
35
Marek Celoud3f552c62017-05-19 18:17:02 +020036 salt.enforceState(master, 'I@salt:control', 'linux.system.service', true)
Ales Komarekef2bab62017-04-26 11:48:28 +020037 salt.enforceState(master, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010038 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
39 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010040
Ales Komarekef2bab62017-04-26 11:48:28 +020041 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010042
Marek Celoud3f552c62017-05-19 18:17:02 +020043 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
44 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010045}
Jakub Josef79ecec32017-02-17 14:36:28 +010046
Ales Komarekef2bab62017-04-26 11:48:28 +020047def installOpenstackInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010048 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020049
Jakub Josef79ecec32017-02-17 14:36:28 +010050 // Install glusterfs
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010051 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010052
Ales Komarekef2bab62017-04-26 11:48:28 +020053 // Install keepaliveds
54 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
55 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
56 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
57
58 // Check the keepalived VIPs
59 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
60
61 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
62
63 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
64 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010065
Jakub Josef79ecec32017-02-17 14:36:28 +010066 // Install rabbitmq
Ales Komarekef2bab62017-04-26 11:48:28 +020067 withEnv(['ASK_ON_ERROR=false']){
68 retry(2) {
69 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
70 }
71 }
72
Jakub Josef79ecec32017-02-17 14:36:28 +010073 // Check the rabbitmq status
74 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
Ales Komarekef2bab62017-04-26 11:48:28 +020075
Jakub Josef79ecec32017-02-17 14:36:28 +010076 // Install galera
Ales Komarekef2bab62017-04-26 11:48:28 +020077 withEnv(['ASK_ON_ERROR=false']){
78 retry(2) {
79 salt.enforceState(master, 'I@galera:master', 'galera', true)
80 }
81 }
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010082 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Ales Komarekef2bab62017-04-26 11:48:28 +020083
Jakub Josef79ecec32017-02-17 14:36:28 +010084 // Check galera status
85 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
86 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Ales Komarekef2bab62017-04-26 11:48:28 +020087
88 // // Setup mysql client
89 // salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
90
Jakub Josef79ecec32017-02-17 14:36:28 +010091 // Install haproxy
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010092 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010093 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
94 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
Ales Komarekef2bab62017-04-26 11:48:28 +020095
Jakub Josef79ecec32017-02-17 14:36:28 +010096 // Install memcached
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010097 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010098}
99
100
Ales Komarekef2bab62017-04-26 11:48:28 +0200101def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100102 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200103
104 // Install horizon dashboard
105 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
106 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
107
Jakub Josef79ecec32017-02-17 14:36:28 +0100108 // setup keystone service
109 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200110 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100111 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100112 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100113
114 // keystone:client must be called locally
Ales Komarekef2bab62017-04-26 11:48:28 +0200115 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
116 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
117 sleep(30)
118 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
119 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
120 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100121
Jakub Josef79ecec32017-02-17 14:36:28 +0100122 // Install glance and ensure glusterfs clusters
123 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200124 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100125 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
126 salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200127
Jakub Josef79ecec32017-02-17 14:36:28 +0100128 // Update fernet tokens before doing request on keystone server
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100129 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200130
Jakub Josef79ecec32017-02-17 14:36:28 +0100131 // Check glance service
Ales Komarekef2bab62017-04-26 11:48:28 +0200132 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
133
Jakub Josef79ecec32017-02-17 14:36:28 +0100134 // Install and check nova service
135 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200136 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
137 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
138 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
139
Jakub Josef79ecec32017-02-17 14:36:28 +0100140 // Install and check cinder service
141 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200142 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100143 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200144 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
145
Jakub Josef79ecec32017-02-17 14:36:28 +0100146 // Install neutron service
147 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200148
149 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
150 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
151 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
152
Jakub Josef79ecec32017-02-17 14:36:28 +0100153 // Install heat service
154 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200155 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100156 salt.enforceState(master, 'I@heat:server', 'heat', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200157 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
158
159 // Restart nova api
160 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
Jakub Josef79ecec32017-02-17 14:36:28 +0100161}
162
163
Ales Komarekef2bab62017-04-26 11:48:28 +0200164def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100165 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200166
167 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
168}
169
170
171def installOpenstackCompute(master) {
172 def salt = new com.mirantis.mk.Salt()
173
174 // Configure compute nodes
175 retry(2) {
Marek Celoude305ec72017-05-16 11:27:53 +0200176 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200177 }
178}
179
180
181def installContrailNetwork(master) {
182 def salt = new com.mirantis.mk.Salt()
183
184
Jakub Josef79ecec32017-02-17 14:36:28 +0100185 // Install opencontrail database services
186 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200187 try {
188 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
189 } catch (Exception e) {
190 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
191 }
192
193 try {
194 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
195 } catch (Exception e) {
196 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
197 }
198
Jakub Josef79ecec32017-02-17 14:36:28 +0100199 // Install opencontrail control services
200 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200201 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
202 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
203 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100204
Jakub Josef79ecec32017-02-17 14:36:28 +0100205 // Test opencontrail
Ales Komarekef2bab62017-04-26 11:48:28 +0200206 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100207}
208
209
Ales Komarekef2bab62017-04-26 11:48:28 +0200210def installContrailCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100211 def salt = new com.mirantis.mk.Salt()
212 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200213 // Provision opencontrail control services
214 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100215 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100216
Ales Komarekef2bab62017-04-26 11:48:28 +0200217 salt.runSaltProcessStep(master, 'I@nova:compute', 'cmd.run', ['exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "'], null, true)
218 sleep(300)
Marek Celoude305ec72017-05-16 11:27:53 +0200219 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100220}
221
222
Ales Komarekef2bab62017-04-26 11:48:28 +0200223def installKubernetesInfra(master) {
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200224 def common = new com.mirantis.mk.Common()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200225 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200226
Jakub Josef79ecec32017-02-17 14:36:28 +0100227 // Install glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200228 if (common.checkContains('INSTALL', 'glusterfs')) {
229 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
230 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200231
Jakub Josef79ecec32017-02-17 14:36:28 +0100232 // Install keepalived
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200233 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
234 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
Ales Komarekef2bab62017-04-26 11:48:28 +0200235
Jakub Josef79ecec32017-02-17 14:36:28 +0100236 // Setup glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200237 if (common.checkContains('INSTALL', 'glusterfs')) {
238 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup')
239 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
240 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
241 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200242
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 // Install haproxy
Tomáš Kukrál7c99e322017-05-02 11:31:31 +0200244 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
Jakub Josef79ecec32017-02-17 14:36:28 +0100245 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200246
Jakub Josef79ecec32017-02-17 14:36:28 +0100247 // Install docker
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200248 salt.enforceState(master, 'I@docker:host', 'docker.host')
Jakub Josef79ecec32017-02-17 14:36:28 +0100249 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200250
Jakub Josef79ecec32017-02-17 14:36:28 +0100251 // Install etcd
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200252 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200253 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
254
Jakub Josef79ecec32017-02-17 14:36:28 +0100255}
256
257
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200258def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200260
Jakub Josef79ecec32017-02-17 14:36:28 +0100261 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200262 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
263 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100264
265 // Setup etcd server
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200266 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100267
268 // Run k8s without master.setup
269 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
270
271 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200272 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100273
274 // Restart kubelet
275 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
276}
277
278
Ales Komarekef2bab62017-04-26 11:48:28 +0200279def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200280 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100281 // Install opencontrail
282 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
283 // Reboot compute nodes
284 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
285}
286
287
288def installStacklightControl(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200289 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200290
291 // infra install
292 // Install the StackLight backends
293 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
294 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
295
296 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
297 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
298
299 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
300 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
301
302 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
303 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
304
305 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
306 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
307 salt.enforceState(master, 'I@kibana:client', 'kibana.client.service', true)
308
309 sleep(10)
310}
311
312def installStacklightClient(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200313 def salt = new com.mirantis.mk.Salt()
314 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200315
316 salt.runSaltProcessStep(master, 'I@elasticsearch.client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
317 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
318 salt.runSaltProcessStep(master, 'I@kibana.client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
319 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
320
321 // Install collectd, heka and sensu services on the nodes, this will also
322 // generate the metadata that goes into the grains and eventually into Salt Mine
323 salt.enforceState(master, '*', 'collectd', true)
324 salt.enforceState(master, '*', 'salt.minion', true)
325 salt.enforceState(master, '*', 'heka', true)
326
327 // Gather the Grafana metadata as grains
328 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
329
330 // Update Salt Mine
331 salt.enforceState(master, '*', 'salt.minion.grains', true)
332 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
333 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
334
335 sleep(5)
336
337 // Update Heka
338 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
339
340 // Update collectd
341 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
342
343 // Update Nagios
344 salt.enforceState(master, 'I@nagios:server', 'nagios', true)
345 // Stop the Nagios service because the package starts it by default and it will
346 // started later only on the node holding the VIP address
347 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
348
349 // Update Sensu
350 // TODO for stacklight team, should be fixed in model
351 //salt.enforceState(master, 'I@sensu:server', 'sensu', true)
352
353 // Finalize the configuration of Grafana (add the dashboards...)
354 salt.enforceState(master, 'I@grafana:client', 'grafana.client.service', true)
355 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
356
357 salt.runSaltProcessStep(master, 'I@grafana.client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true)
358 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
359
360 // Get the StackLight monitoring VIP addres
361 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
362 //vip=${vip:=172.16.10.253}
363 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
364 print(common.prettyPrint(pillar))
365 def stacklight_vip = pillar['return'][0].values()[0]
366
367 if (stacklight_vip) {
368 // (re)Start manually the services that are bound to the monitoring VIP
369 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
370 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
371 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
372 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
373 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
374 } else {
375 throw new Exception("Missing stacklight_vip")
376 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100377}