blob: 20e6d641399a07a3c7ef844c31848ae62e7e120f [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) {
Martin Polreichfc9854c2017-06-30 11:17:36 +0200189 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200190 def salt = new com.mirantis.mk.Salt()
191
192
Jakub Josef79ecec32017-02-17 14:36:28 +0100193 // Install opencontrail database services
194 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200195 try {
196 salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true)
197 } catch (Exception e) {
198 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*')
199 }
200
201 try {
202 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
203 } catch (Exception e) {
204 common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database')
205 }
206
Jakub Josef79ecec32017-02-17 14:36:28 +0100207 // Install opencontrail control services
208 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Ales Komarekef2bab62017-04-26 11:48:28 +0200209 salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
210 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
211 salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100212
Jakub Josef79ecec32017-02-17 14:36:28 +0100213 // Test opencontrail
Ales Komarekef2bab62017-04-26 11:48:28 +0200214 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100215}
216
217
Ales Komarekef2bab62017-04-26 11:48:28 +0200218def installContrailCompute(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100219 def salt = new com.mirantis.mk.Salt()
220 // Configure compute nodes
Ales Komarekef2bab62017-04-26 11:48:28 +0200221 // Provision opencontrail control services
222 salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100223 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100224
Ales Komarekef2bab62017-04-26 11:48:28 +0200225 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)
226 sleep(300)
Marek Celoude305ec72017-05-16 11:27:53 +0200227 salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100228}
229
230
Ales Komarekef2bab62017-04-26 11:48:28 +0200231def installKubernetesInfra(master) {
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200232 def common = new com.mirantis.mk.Common()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200233 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200234
Jakub Josef79ecec32017-02-17 14:36:28 +0100235 // Install glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200236 if (common.checkContains('INSTALL', 'glusterfs')) {
237 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service')
238 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200239
Jakub Josef79ecec32017-02-17 14:36:28 +0100240 // Install keepalived
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200241 salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived')
242 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived')
Ales Komarekef2bab62017-04-26 11:48:28 +0200243
Jakub Josef79ecec32017-02-17 14:36:28 +0100244 // Setup glusterfs
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200245 if (common.checkContains('INSTALL', 'glusterfs')) {
Alexander Noskov93acac42017-06-20 17:55:55 +0200246 withEnv(['ASK_ON_ERROR=false']){
247 retry(5) {
248 salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup')
249 }
250 }
Tomáš Kukrál0ea82db2017-05-02 11:16:05 +0200251 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
252 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
253 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200254
Jakub Josef79ecec32017-02-17 14:36:28 +0100255 // Install haproxy
Tomáš Kukrál7c99e322017-05-02 11:31:31 +0200256 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy')
Jakub Josef79ecec32017-02-17 14:36:28 +0100257 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200258
Jakub Josef79ecec32017-02-17 14:36:28 +0100259 // Install docker
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200260 salt.enforceState(master, 'I@docker:host', 'docker.host')
Jakub Josef79ecec32017-02-17 14:36:28 +0100261 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
Ales Komarekef2bab62017-04-26 11:48:28 +0200262
Jakub Josef79ecec32017-02-17 14:36:28 +0100263 // Install etcd
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200264 salt.enforceState(master, 'I@etcd:server', 'etcd.server.service')
Ales Komarekef2bab62017-04-26 11:48:28 +0200265 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
266
Jakub Josef79ecec32017-02-17 14:36:28 +0100267}
268
269
Tomáš Kukrálc1a1bbc2017-04-28 21:16:25 +0200270def installKubernetesControl(master) {
Jakub Josef79ecec32017-02-17 14:36:28 +0100271 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200272
Jakub Josef79ecec32017-02-17 14:36:28 +0100273 // Install Kubernetes pool and Calico
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200274 salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons')
275 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
Jakub Josef79ecec32017-02-17 14:36:28 +0100276
277 // Setup etcd server
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200278 salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100279
280 // Run k8s without master.setup
281 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
282
283 // Run k8s master setup
Tomáš Kukrálb05cf002017-05-02 11:05:43 +0200284 salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup')
Jakub Josef79ecec32017-02-17 14:36:28 +0100285
286 // Restart kubelet
287 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
288}
289
290
Ales Komarekef2bab62017-04-26 11:48:28 +0200291def installKubernetesCompute(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200292 def salt = new com.mirantis.mk.Salt()
Tomáš Kukrále7e28962017-06-06 11:11:16 +0200293
294 // Refresh minion's pillar data
295 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
296 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
297
298 // Bootstrap all nodes
299 salt.enforceState(master, 'I@kubernetes:pool', 'linux')
300 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion')
301 salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp'])
302
303 // Create and distribute SSL certificates for services using salt state
304 salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert')
305
306 // Install docker
307 salt.enforceState(master, 'I@docker:host', 'docker.host')
308
309 // Install Kubernetes and Calico
310 salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool')
311
312}
313
314
315def installKubernetesContrailCompute(master) {
316 def salt = new com.mirantis.mk.Salt()
Jakub Josef79ecec32017-02-17 14:36:28 +0100317 // Install opencontrail
318 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
319 // Reboot compute nodes
320 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
321}
322
323
324def installStacklightControl(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200325 def salt = new com.mirantis.mk.Salt()
Ales Komarekef2bab62017-04-26 11:48:28 +0200326
327 // infra install
328 // Install the StackLight backends
329 salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true)
330 salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true)
331
332 salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true)
333 salt.enforceState(master, 'I@influxdb:server', 'influxdb', true)
334
335 salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true)
336 salt.enforceState(master, 'I@kibana:server', 'kibana.server', true)
337
338 salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true)
339 salt.enforceState(master, 'I@grafana:server','grafana.server', true)
340
Kalynovskyi3e370112017-06-26 12:48:23 +0300341 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
342 def alarming_service = alarming_service_pillar['return'][0].values()[0]
343
344 switch (alarming_service) {
345 case 'sensu':
346 // Update Sensu
347 salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true)
348 salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true)
349 salt.enforceState(master, 'I@redis:server', 'redis', true)
350 salt.enforceState(master, 'I@sensu:server', 'sensu', true)
351 default:
352 // Update Nagios
353 salt.enforceState(master, 'I@nagios:server', 'nagios.server', true)
354 // Stop the Nagios service because the package starts it by default and it will
355 // started later only on the node holding the VIP address
356 salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true)
357 }
358
Ales Komarekef2bab62017-04-26 11:48:28 +0200359 salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true)
Marek Celoudebc623b2017-06-02 17:12:31 +0200360 salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200361
362 sleep(10)
363}
364
365def installStacklightClient(master) {
Tomáš Kukrála53b5352017-05-04 11:45:53 +0200366 def salt = new com.mirantis.mk.Salt()
367 def common = new com.mirantis.mk.Common()
Ales Komarekef2bab62017-04-26 11:48:28 +0200368
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200369 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200370 // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true)
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200371 salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true)
Ales Komarekef2bab62017-04-26 11:48:28 +0200372 // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true)
373
374 // Install collectd, heka and sensu services on the nodes, this will also
375 // generate the metadata that goes into the grains and eventually into Salt Mine
376 salt.enforceState(master, '*', 'collectd', true)
377 salt.enforceState(master, '*', 'salt.minion', true)
378 salt.enforceState(master, '*', 'heka', true)
379
380 // Gather the Grafana metadata as grains
381 salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true)
382
383 // Update Salt Mine
384 salt.enforceState(master, '*', 'salt.minion.grains', true)
385 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true)
386 salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true)
387
388 sleep(5)
389
390 // Update Heka
391 salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true)
392
393 // Update collectd
394 salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true)
395
Kalynovskyi3e370112017-06-26 12:48:23 +0300396 def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service')
397 def alarming_service = alarming_service_pillar['return'][0].values()[0]
Ales Komarekef2bab62017-04-26 11:48:28 +0200398
Kalynovskyi3e370112017-06-26 12:48:23 +0300399 switch (alarming_service) {
400 case 'sensu':
401 // Update Sensu
402 // TODO for stacklight team, should be fixed in model
403 salt.enforceState(master, 'I@sensu:client', 'sensu', true)
404 default:
405 break
406 // Default is nagios, and was enforced in installStacklightControl()
407 }
Ales Komarekef2bab62017-04-26 11:48:28 +0200408
Alexander Noskov3c6a60a2017-06-21 14:05:07 +0200409 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 +0200410 // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
411
Marek Celoudd200cad2017-06-07 10:34:46 +0200412 // Finalize the configuration of Grafana (add the dashboards...)
Alexander Noskov8448fc52017-06-21 14:03:45 +0200413 salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true)
414 salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true)
415 salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true)
Marek Celoudd200cad2017-06-07 10:34:46 +0200416 // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10
417
Ales Komarekef2bab62017-04-26 11:48:28 +0200418 // Get the StackLight monitoring VIP addres
419 //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}')
420 //vip=${vip:=172.16.10.253}
421 def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address')
Jakub Josefbceaa322017-06-13 18:28:27 +0200422 common.prettyPrint(pillar)
Ales Komarekef2bab62017-04-26 11:48:28 +0200423 def stacklight_vip = pillar['return'][0].values()[0]
424
425 if (stacklight_vip) {
426 // (re)Start manually the services that are bound to the monitoring VIP
427 common.infoMsg("restart services on node with IP: ${stacklight_vip}")
428 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true)
429 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true)
430 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true)
431 salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true)
432 } else {
433 throw new Exception("Missing stacklight_vip")
434 }
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100435}