blob: b737e6cd7ed8964b5dd7b8c60c821d418eddc9f6 [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)
22 salt.enforceState(master, '*', ['linux.system'], true)
23 salt.enforceState(master, '*', ['salt.minion'], true)
24 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
25 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
26 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010027}
28
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010029def installInfraKvm(master) {
30 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010031
Ales Komarekef2bab62017-04-26 11:48:28 +020032 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
33 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
34
35 salt.enforceState(master, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010036 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
37 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010038
Ales Komarekef2bab62017-04-26 11:48:28 +020039 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010040
Ales Komarekef2bab62017-04-26 11:48:28 +020041 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true)
42 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010043}
Jakub Josef79ecec32017-02-17 14:36:28 +010044
Ales Komarekef2bab62017-04-26 11:48:28 +020045def installOpenstackInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010046 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020047
Jakub Josef79ecec32017-02-17 14:36:28 +010048 // Install glusterfs
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010049 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010050
Ales Komarekef2bab62017-04-26 11:48:28 +020051 // Install keepaliveds
52 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
53 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
54 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
55
56 // Check the keepalived VIPs
57 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
58
59 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
60
61 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
62 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010063
Jakub Josef79ecec32017-02-17 14:36:28 +010064 // Install rabbitmq
Ales Komarekef2bab62017-04-26 11:48:28 +020065 withEnv(['ASK_ON_ERROR=false']){
66 retry(2) {
67 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
68 }
69 }
70
Jakub Josef79ecec32017-02-17 14:36:28 +010071 // Check the rabbitmq status
72 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
Ales Komarekef2bab62017-04-26 11:48:28 +020073
Jakub Josef79ecec32017-02-17 14:36:28 +010074 // Install galera
Ales Komarekef2bab62017-04-26 11:48:28 +020075 withEnv(['ASK_ON_ERROR=false']){
76 retry(2) {
77 salt.enforceState(master, 'I@galera:master', 'galera', true)
78 }
79 }
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010080 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Ales Komarekef2bab62017-04-26 11:48:28 +020081
Jakub Josef79ecec32017-02-17 14:36:28 +010082 // Check galera status
83 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
84 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Ales Komarekef2bab62017-04-26 11:48:28 +020085
86 // // Setup mysql client
87 // salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
88
Jakub Josef79ecec32017-02-17 14:36:28 +010089 // Install haproxy
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010090 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010091 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
92 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
Ales Komarekef2bab62017-04-26 11:48:28 +020093
Jakub Josef79ecec32017-02-17 14:36:28 +010094 // Install memcached
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010095 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010096}
97
98
Ales Komarekef2bab62017-04-26 11:48:28 +020099def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100100 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200101
102 // Install horizon dashboard
103 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
104 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
105
Jakub Josef79ecec32017-02-17 14:36:28 +0100106 // setup keystone service
107 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200108 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100109 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100110 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100111
112 // keystone:client must be called locally
Ales Komarekef2bab62017-04-26 11:48:28 +0200113 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
114 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
115 sleep(30)
116 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
117 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
118 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100119
Jakub Josef79ecec32017-02-17 14:36:28 +0100120 // Install glance and ensure glusterfs clusters
121 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200122 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100123 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
124 salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200125
Jakub Josef79ecec32017-02-17 14:36:28 +0100126 // Update fernet tokens before doing request on keystone server
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100127 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200128
Jakub Josef79ecec32017-02-17 14:36:28 +0100129 // Check glance service
Ales Komarekef2bab62017-04-26 11:48:28 +0200130 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
131
Jakub Josef79ecec32017-02-17 14:36:28 +0100132 // Install and check nova service
133 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200134 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
135 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
136 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
137
Jakub Josef79ecec32017-02-17 14:36:28 +0100138 // Install and check cinder service
139 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200140 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100141 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200142 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
143
Jakub Josef79ecec32017-02-17 14:36:28 +0100144 // Install neutron service
145 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200146
147 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
148 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
149 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
150
Jakub Josef79ecec32017-02-17 14:36:28 +0100151 // Install heat service
152 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200153 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100154 salt.enforceState(master, 'I@heat:server', 'heat', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200155 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
156
157 // Restart nova api
158 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
Jakub Josef79ecec32017-02-17 14:36:28 +0100159}
160
161
Ales Komarekef2bab62017-04-26 11:48:28 +0200162def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100163 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200164
165 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
166}
167
168
169def installOpenstackCompute(master) {
170 def salt = new com.mirantis.mk.Salt()
171
172 // Configure compute nodes
173 retry(2) {
174 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply', [], null, true)
175 }
176}
177
178
179def installContrailNetwork(master) {
180 def salt = new com.mirantis.mk.Salt()
181
182
Jakub Josef79ecec32017-02-17 14:36:28 +0100183 // Install opencontrail database services
184 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200185 try {
186 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
187 } catch (Exception e) {
188 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
189 }
190
191 try {
192 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
193 } catch (Exception e) {
194 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
195 }
196
Jakub Josef79ecec32017-02-17 14:36:28 +0100197 // Install opencontrail control services
198 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200199 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
200 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
201 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100202
Jakub Josef79ecec32017-02-17 14:36:28 +0100203 // Test opencontrail
Ales Komarekef2bab62017-04-26 11:48:28 +0200204 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100205}
206
207
Ales Komarekef2bab62017-04-26 11:48:28 +0200208def installContrailCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100209 def salt = new com.mirantis.mk.Salt()
210 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200211 // Provision opencontrail control services
212 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100213 // Provision opencontrail virtual routers
Ales Komarekef2bab62017-04-26 11:48:28 +0200214 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100215
Ales Komarekef2bab62017-04-26 11:48:28 +0200216 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)
217 sleep(300)
Jakub Josef79ecec32017-02-17 14:36:28 +0100218}
219
220
Ales Komarekef2bab62017-04-26 11:48:28 +0200221def installKubernetesInfra(master) {
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200222 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200223
Jakub Josef79ecec32017-02-17 14:36:28 +0100224 // Install glusterfs
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200225 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200226
Jakub Josef79ecec32017-02-17 14:36:28 +0100227 // Install keepalived
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200228 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
229 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
Ales Komarekef2bab62017-04-26 11:48:28 +0200230
Jakub Josef79ecec32017-02-17 14:36:28 +0100231 // Setup glusterfs
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200232 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100233 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
234 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200235
Jakub Josef79ecec32017-02-17 14:36:28 +0100236 // Install haproxy
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200237 salt.enforceState(master, 'I@haproxy:proxy', 'state.sls', 'haproxy')
Jakub Josef79ecec32017-02-17 14:36:28 +0100238 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200239
Jakub Josef79ecec32017-02-17 14:36:28 +0100240 // Install docker
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200241 salt.enforceState(master, 'I@docker:host', 'docker.host')
Jakub Josef79ecec32017-02-17 14:36:28 +0100242 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200243
Jakub Josef79ecec32017-02-17 14:36:28 +0100244 // Install etcd
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200245 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200246 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
247
Jakub Josef79ecec32017-02-17 14:36:28 +0100248}
249
250
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200251def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100252 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200253
Jakub Josef79ecec32017-02-17 14:36:28 +0100254 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200255 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
256 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100257
258 // Setup etcd server
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200259 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100260
261 // Run k8s without master.setup
262 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
263
264 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200265 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100266
267 // Restart kubelet
268 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
269}
270
271
Ales Komarekef2bab62017-04-26 11:48:28 +0200272def installKubernetesCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100273 def salt = new com.mirantis.mk.Salt();
274 // Install opencontrail
275 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
276 // Reboot compute nodes
277 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
278}
279
280
281def installStacklightControl(master) {
282 def salt = new com.mirantis.mk.Salt();
Ales Komarekef2bab62017-04-26 11:48:28 +0200283
284 // infra install
285 // Install the StackLight backends
286 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
287 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
288
289 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
290 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
291
292 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
293 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
294
295 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
296 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
297
298 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
299 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
300 salt.enforceState(master, 'I@kibana:client', 'kibana.client.service', true)
301
302 sleep(10)
303}
304
305def installStacklightClient(master) {
306 def salt = new com.mirantis.mk.Salt();
307
308 salt.runSaltProcessStep(master, 'I@elasticsearch.client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
309 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
310 salt.runSaltProcessStep(master, 'I@kibana.client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
311 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
312
313 // Install collectd, heka and sensu services on the nodes, this will also
314 // generate the metadata that goes into the grains and eventually into Salt Mine
315 salt.enforceState(master, '*', 'collectd', true)
316 salt.enforceState(master, '*', 'salt.minion', true)
317 salt.enforceState(master, '*', 'heka', true)
318
319 // Gather the Grafana metadata as grains
320 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
321
322 // Update Salt Mine
323 salt.enforceState(master, '*', 'salt.minion.grains', true)
324 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
325 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
326
327 sleep(5)
328
329 // Update Heka
330 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
331
332 // Update collectd
333 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
334
335 // Update Nagios
336 salt.enforceState(master, 'I@nagios:server', 'nagios', true)
337 // Stop the Nagios service because the package starts it by default and it will
338 // started later only on the node holding the VIP address
339 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
340
341 // Update Sensu
342 // TODO for stacklight team, should be fixed in model
343 //salt.enforceState(master, 'I@sensu:server', 'sensu', true)
344
345 // Finalize the configuration of Grafana (add the dashboards...)
346 salt.enforceState(master, 'I@grafana:client', 'grafana.client.service', true)
347 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
348
349 salt.runSaltProcessStep(master, 'I@grafana.client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true)
350 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
351
352 // Get the StackLight monitoring VIP addres
353 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
354 //vip=${vip:=172.16.10.253}
355 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
356 print(common.prettyPrint(pillar))
357 def stacklight_vip = pillar['return'][0].values()[0]
358
359 if (stacklight_vip) {
360 // (re)Start manually the services that are bound to the monitoring VIP
361 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
362 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
363 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
364 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
365 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
366 } else {
367 throw new Exception("Missing stacklight_vip")
368 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100369}