blob: ac9058227369433097f4739250cec4bce8f9118a [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)
Tomáš Kukrálb4d75222017-06-06 10:36:02 +020022
23 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
24 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
25
26 salt.enforceState(master, 'I@salt:master', ['linux.system'], true)
27 salt.enforceState(master, 'I@salt:master', ['salt.minion'], true)
28
Jakub Josef200550f2017-05-16 17:39:55 +020029 salt.enforceState(master, '*', ['linux.system'], true)
30 salt.enforceState(master, '*', ['salt.minion'], true)
Ales Komarekef2bab62017-04-26 11:48:28 +020031 salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Jakub Josef79ecec32017-02-17 14:36:28 +010032}
33
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010034def installInfraKvm(master) {
35 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010036
Ales Komarekef2bab62017-04-26 11:48:28 +020037 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
38 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true)
39
40 salt.enforceState(master, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010041 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
42 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010043
Ales Komarekef2bab62017-04-26 11:48:28 +020044 sleep(600)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010045
Marek Celoudc9b3cc82017-05-22 12:50:53 +000046 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true)
47 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true)
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010048}
Jakub Josef79ecec32017-02-17 14:36:28 +010049
Ales Komarekef2bab62017-04-26 11:48:28 +020050def installOpenstackInfra(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +010051 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +020052
Jakub Josef79ecec32017-02-17 14:36:28 +010053 // Install glusterfs
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010054 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010055
Ales Komarekef2bab62017-04-26 11:48:28 +020056 // Install keepaliveds
57 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
58 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true)
59 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
60
61 // Check the keepalived VIPs
62 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
63
Alexander Noskov93acac42017-06-20 17:55:55 +020064 withEnv(['ASK_ON_ERROR=false']){
65 retry(5) {
66 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true)
67 }
68 }
Ales Komarekef2bab62017-04-26 11:48:28 +020069
70 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
71 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010072
Jakub Josef79ecec32017-02-17 14:36:28 +010073 // Install rabbitmq
Ales Komarekef2bab62017-04-26 11:48:28 +020074 withEnv(['ASK_ON_ERROR=false']){
75 retry(2) {
76 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
77 }
78 }
79
Jakub Josef79ecec32017-02-17 14:36:28 +010080 // Check the rabbitmq status
81 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
Ales Komarekef2bab62017-04-26 11:48:28 +020082
Jakub Josef79ecec32017-02-17 14:36:28 +010083 // Install galera
Ales Komarekef2bab62017-04-26 11:48:28 +020084 withEnv(['ASK_ON_ERROR=false']){
85 retry(2) {
86 salt.enforceState(master, 'I@galera:master', 'galera', true)
87 }
88 }
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010089 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Ales Komarekef2bab62017-04-26 11:48:28 +020090
Jakub Josef79ecec32017-02-17 14:36:28 +010091 // Check galera status
92 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
93 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
Ales Komarekef2bab62017-04-26 11:48:28 +020094
95 // // Setup mysql client
96 // salt.enforceState(master, 'I@mysql:client', 'mysql.client', true)
97
Jakub Josef79ecec32017-02-17 14:36:28 +010098 // Install haproxy
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010099 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100100 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
101 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200102
Jakub Josef79ecec32017-02-17 14:36:28 +0100103 // Install memcached
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100104 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100105}
106
107
Ales Komarekef2bab62017-04-26 11:48:28 +0200108def installOpenstackControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100109 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200110
111 // Install horizon dashboard
112 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
113 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
114
Jakub Josef79ecec32017-02-17 14:36:28 +0100115 // setup keystone service
116 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200117 salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100118 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100119 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100120
121 // keystone:client must be called locally
Ales Komarekef2bab62017-04-26 11:48:28 +0200122 //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
123 salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2'])
124 sleep(30)
125 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
126 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
127 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true)
Tomáš Kukrál926e6332017-03-02 09:23:03 +0100128
Jakub Josef79ecec32017-02-17 14:36:28 +0100129 // Install glance and ensure glusterfs clusters
130 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200131 salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100132 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
133 salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200134
Jakub Josef79ecec32017-02-17 14:36:28 +0100135 // Update fernet tokens before doing request on keystone server
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100136 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200137
Jakub Josef79ecec32017-02-17 14:36:28 +0100138 // Check glance service
Ales Komarekef2bab62017-04-26 11:48:28 +0200139 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
140
Jakub Josef79ecec32017-02-17 14:36:28 +0100141 // Install and check nova service
142 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200143 salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true)
144 salt.enforceState(master, 'I@nova:controller', 'nova.controller', true)
145 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
146
Jakub Josef79ecec32017-02-17 14:36:28 +0100147 // Install and check cinder service
148 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200149 salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100150 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200151 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
152
Jakub Josef79ecec32017-02-17 14:36:28 +0100153 // Install neutron service
154 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200155
156 salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true)
157 salt.enforceState(master, 'I@neutron:server', 'neutron.server', true)
158 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
159
Jakub Josef79ecec32017-02-17 14:36:28 +0100160 // Install heat service
161 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200162 salt.enforceState(master, 'I@heat:server and *01*', 'heat', true)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100163 salt.enforceState(master, 'I@heat:server', 'heat', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200164 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
165
166 // Restart nova api
167 salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api'])
Jakub Josef79ecec32017-02-17 14:36:28 +0100168}
169
170
Ales Komarekef2bab62017-04-26 11:48:28 +0200171def installOpenstackNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100172 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200173
174 salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true)
175}
176
177
178def installOpenstackCompute(master) {
179 def salt = new com.mirantis.mk.Salt()
180
181 // Configure compute nodes
182 retry(2) {
Marek Celoude305ec72017-05-16 11:27:53 +0200183 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200184 }
185}
186
187
188def installContrailNetwork(master) {
189 def salt = new com.mirantis.mk.Salt()
190
191
Jakub Josef79ecec32017-02-17 14:36:28 +0100192 // Install opencontrail database services
193 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200194 try {
195 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
196 } catch (Exception e) {
197 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
198 }
199
200 try {
201 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
202 } catch (Exception e) {
203 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
204 }
205
Jakub Josef79ecec32017-02-17 14:36:28 +0100206 // Install opencontrail control services
207 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200208 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
209 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
210 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100211
Jakub Josef79ecec32017-02-17 14:36:28 +0100212 // Test opencontrail
Ales Komarekef2bab62017-04-26 11:48:28 +0200213 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100214}
215
216
Ales Komarekef2bab62017-04-26 11:48:28 +0200217def installContrailCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100218 def salt = new com.mirantis.mk.Salt()
219 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200220 // Provision opencontrail control services
221 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100222 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100223
Ales Komarekef2bab62017-04-26 11:48:28 +0200224 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)
225 sleep(300)
Marek Celoude305ec72017-05-16 11:27:53 +0200226 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100227}
228
229
Ales Komarekef2bab62017-04-26 11:48:28 +0200230def installKubernetesInfra(master) {
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200231 def common = new com.mirantis.mk.Common()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200232 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200233
Jakub Josef79ecec32017-02-17 14:36:28 +0100234 // Install glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200235 if (common.checkContains('INSTALL', 'glusterfs')) {
236 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
237 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200238
Jakub Josef79ecec32017-02-17 14:36:28 +0100239 // Install keepalived
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200240 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
241 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
Ales Komarekef2bab62017-04-26 11:48:28 +0200242
Jakub Josef79ecec32017-02-17 14:36:28 +0100243 // Setup glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200244 if (common.checkContains('INSTALL', 'glusterfs')) {
Alexander Noskov93acac42017-06-20 17:55:55 +0200245 withEnv(['ASK_ON_ERROR=false']){
246 retry(5) {
247 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup')
248 }
249 }
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200250 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
251 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
252 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200253
Jakub Josef79ecec32017-02-17 14:36:28 +0100254 // Install haproxy
Tomáš Kukrál7c99e322017-05-02 11:31:31 +0200255 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
Jakub Josef79ecec32017-02-17 14:36:28 +0100256 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200257
Jakub Josef79ecec32017-02-17 14:36:28 +0100258 // Install docker
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200259 salt.enforceState(master, 'I@docker:host', 'docker.host')
Jakub Josef79ecec32017-02-17 14:36:28 +0100260 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200261
Jakub Josef79ecec32017-02-17 14:36:28 +0100262 // Install etcd
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200263 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200264 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
265
Jakub Josef79ecec32017-02-17 14:36:28 +0100266}
267
268
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200269def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100270 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200271
Jakub Josef79ecec32017-02-17 14:36:28 +0100272 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200273 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
274 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100275
276 // Setup etcd server
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200277 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100278
279 // Run k8s without master.setup
280 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
281
282 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200283 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100284
285 // Restart kubelet
286 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
287}
288
289
Ales Komarekef2bab62017-04-26 11:48:28 +0200290def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200291 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200292
293 // Refresh minion's pillar data
294 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
295 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
296
297 // Bootstrap all nodes
298 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
299 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
300 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
301
302 // Create and distribute SSL certificates for services using salt state
303 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
304
305 // Install docker
306 salt.enforceState(master, 'I@docker:host', 'docker.host')
307
308 // Install Kubernetes and Calico
309 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
310
311}
312
313
314def installKubernetesContrailCompute(master) {
315 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100316 // Install opencontrail
317 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
318 // Reboot compute nodes
319 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
320}
321
322
323def installStacklightControl(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200324 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200325
326 // infra install
327 // Install the StackLight backends
328 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
329 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
330
331 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
332 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
333
334 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
335 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
336
337 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
338 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
339
340 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
341 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
Marek Celoudebc623b2017-06-02 17:12:31 +0200342 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200343
344 sleep(10)
345}
346
347def installStacklightClient(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200348 def salt = new com.mirantis.mk.Salt()
349 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200350
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200351 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200352 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200353 salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200354 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
355
356 // Install collectd, heka and sensu services on the nodes, this will also
357 // generate the metadata that goes into the grains and eventually into Salt Mine
358 salt.enforceState(master, '*', 'collectd', true)
359 salt.enforceState(master, '*', 'salt.minion', true)
360 salt.enforceState(master, '*', 'heka', true)
361
362 // Gather the Grafana metadata as grains
363 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
364
365 // Update Salt Mine
366 salt.enforceState(master, '*', 'salt.minion.grains', true)
367 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
368 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
369
370 sleep(5)
371
372 // Update Heka
373 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
374
375 // Update collectd
376 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
377
378 // Update Nagios
379 salt.enforceState(master, 'I@nagios:server', 'nagios', true)
380 // Stop the Nagios service because the package starts it by default and it will
381 // started later only on the node holding the VIP address
382 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
383
384 // Update Sensu
385 // TODO for stacklight team, should be fixed in model
386 //salt.enforceState(master, 'I@sensu:server', 'sensu', true)
387
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200388 salt.runSaltProcessStep(master, 'I@grafana:client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200389 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
390
Marek Celoudd200cad2017-06-07 10:34:46 +0200391 // Finalize the configuration of Grafana (add the dashboards...)
Alexander Noskov8448fc52017-06-21 14:03:45 +0200392 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
393 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true)
394 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true)
Marek Celoudd200cad2017-06-07 10:34:46 +0200395 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
396
Ales Komarekef2bab62017-04-26 11:48:28 +0200397 // Get the StackLight monitoring VIP addres
398 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
399 //vip=${vip:=172.16.10.253}
400 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200401 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200402 def stacklight_vip = pillar['return'][0].values()[0]
403
404 if (stacklight_vip) {
405 // (re)Start manually the services that are bound to the monitoring VIP
406 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
407 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
408 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
409 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
410 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
411 } else {
412 throw new Exception("Missing stacklight_vip")
413 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100414}