blob: 3a874cb306f542a4ca5e3cfbfc8688d3531baf18 [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ál0ea82db2017-05-02 11:16:05 +0200222 def common = new com.mirantis.mk.Common()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200223 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200224
Jakub Josef79ecec32017-02-17 14:36:28 +0100225 // Install glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200226 if (common.checkContains('INSTALL', 'glusterfs')) {
227 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
228 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200229
Jakub Josef79ecec32017-02-17 14:36:28 +0100230 // Install keepalived
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200231 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
232 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
Ales Komarekef2bab62017-04-26 11:48:28 +0200233
Jakub Josef79ecec32017-02-17 14:36:28 +0100234 // Setup glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200235 if (common.checkContains('INSTALL', 'glusterfs')) {
236 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup')
237 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
238 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
239 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200240
Jakub Josef79ecec32017-02-17 14:36:28 +0100241 // Install haproxy
Tomáš Kukrál7c99e322017-05-02 11:31:31 +0200242 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200244
Jakub Josef79ecec32017-02-17 14:36:28 +0100245 // Install docker
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200246 salt.enforceState(master, 'I@docker:host', 'docker.host')
Jakub Josef79ecec32017-02-17 14:36:28 +0100247 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200248
Jakub Josef79ecec32017-02-17 14:36:28 +0100249 // Install etcd
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200250 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200251 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
252
Jakub Josef79ecec32017-02-17 14:36:28 +0100253}
254
255
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200256def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100257 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200258
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200260 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
261 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100262
263 // Setup etcd server
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200264 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100265
266 // Run k8s without master.setup
267 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
268
269 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200270 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100271
272 // Restart kubelet
273 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
274}
275
276
Ales Komarekef2bab62017-04-26 11:48:28 +0200277def installKubernetesCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100278 def salt = new com.mirantis.mk.Salt();
279 // Install opencontrail
280 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
281 // Reboot compute nodes
282 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
283}
284
285
286def installStacklightControl(master) {
287 def salt = new com.mirantis.mk.Salt();
Ales Komarekef2bab62017-04-26 11:48:28 +0200288
289 // infra install
290 // Install the StackLight backends
291 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
292 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
293
294 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
295 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
296
297 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
298 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
299
300 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
301 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
302
303 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
304 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
305 salt.enforceState(master, 'I@kibana:client', 'kibana.client.service', true)
306
307 sleep(10)
308}
309
310def installStacklightClient(master) {
311 def salt = new com.mirantis.mk.Salt();
312
313 salt.runSaltProcessStep(master, 'I@elasticsearch.client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
314 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
315 salt.runSaltProcessStep(master, 'I@kibana.client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
316 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
317
318 // Install collectd, heka and sensu services on the nodes, this will also
319 // generate the metadata that goes into the grains and eventually into Salt Mine
320 salt.enforceState(master, '*', 'collectd', true)
321 salt.enforceState(master, '*', 'salt.minion', true)
322 salt.enforceState(master, '*', 'heka', true)
323
324 // Gather the Grafana metadata as grains
325 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
326
327 // Update Salt Mine
328 salt.enforceState(master, '*', 'salt.minion.grains', true)
329 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
330 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
331
332 sleep(5)
333
334 // Update Heka
335 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
336
337 // Update collectd
338 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
339
340 // Update Nagios
341 salt.enforceState(master, 'I@nagios:server', 'nagios', true)
342 // Stop the Nagios service because the package starts it by default and it will
343 // started later only on the node holding the VIP address
344 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
345
346 // Update Sensu
347 // TODO for stacklight team, should be fixed in model
348 //salt.enforceState(master, 'I@sensu:server', 'sensu', true)
349
350 // Finalize the configuration of Grafana (add the dashboards...)
351 salt.enforceState(master, 'I@grafana:client', 'grafana.client.service', true)
352 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
353
354 salt.runSaltProcessStep(master, 'I@grafana.client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true)
355 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
356
357 // Get the StackLight monitoring VIP addres
358 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
359 //vip=${vip:=172.16.10.253}
360 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
361 print(common.prettyPrint(pillar))
362 def stacklight_vip = pillar['return'][0].values()[0]
363
364 if (stacklight_vip) {
365 // (re)Start manually the services that are bound to the monitoring VIP
366 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
367 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
368 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
369 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
370 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
371 } else {
372 throw new Exception("Missing stacklight_vip")
373 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100374}