blob: bb22f87a98e33ad164fd191484248b5f6098b316 [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()
9 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['salt-key'])
10 salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version')
11 salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['reclass-salt --top'])
12 salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory')
13 salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top')
14}
15
16
17def installFoundationInfra(master) {
18 def salt = new com.mirantis.mk.Salt()
19 salt.runSaltProcessStep(master, 'I@salt:master', 'state.sls', ['salt.master,reclass'])
Bartosz Kupidurab2956982017-03-29 12:35:23 +020020 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar')
21 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all')
Jakub Josef79ecec32017-02-17 14:36:28 +010022 salt.runSaltProcessStep(master, 'I@linux:system', 'state.sls', ['linux,openssh,salt.minion,ntp'])
23}
24
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010025def installInfraKvm(master) {
26 def salt = new com.mirantis.mk.Salt()
27 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar')
28 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all')
29
30 salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['salt.minion,linux.system,linux.network,ntp'])
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010031 salt.enforceState(master, 'I@salt:control', 'libvirt', true)
32 salt.enforceState(master, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010033
Tomáš Kukráladf83952017-03-01 18:10:50 +010034 sleep(300)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010035
Tomáš Kukráladf83952017-03-01 18:10:50 +010036 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar')
37 salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010038
Tomáš Kukrál926e6332017-03-02 09:23:03 +010039 // workaround - install apt-transport-https
40 salt.runSaltProcessStep(master, '* and not kvm*', 'pkg.install', ['apt-transport-https'])
41
42 salt.runSaltProcessStep(master, '* and not kvm*', 'state.sls', ['linux,openssh,salt.minion,ntp'])
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010043}
Jakub Josef79ecec32017-02-17 14:36:28 +010044
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010045def installOpenstackMkInfra(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +010046 def salt = new com.mirantis.mk.Salt()
47 // Install keepaliveds
48 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010049 salt.enforceState(master, 'ctl01*', 'keepalived', true)
50 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010051 // Check the keepalived VIPs
52 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
53 // 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
Jakub Josef79ecec32017-02-17 14:36:28 +010056 //runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010057 if (physical.equals("false")) {
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010058 salt.enforceState(master, 'ctl01*', 'glusterfs.server.setup', true)
59 salt.enforceState(master, 'ctl02*', 'glusterfs.server.setup', true)
60 salt.enforceState(master, 'ctl03*', 'glusterfs.server.setup', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010061 } else {
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010062 salt.enforceState(master, 'kvm01*', 'glusterfs.server.setup', true)
63 salt.enforceState(master, 'kvm02*', 'glusterfs.server.setup', true)
64 salt.enforceState(master, 'kvm03*', 'glusterfs.server.setup', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010065 }
Jakub Josef79ecec32017-02-17 14:36:28 +010066 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
67 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010068
Jakub Josef79ecec32017-02-17 14:36:28 +010069 // Install rabbitmq
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010070 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010071 // Check the rabbitmq status
72 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
73 // Install galera
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010074 salt.enforceState(master, 'I@galera:master', 'galera', true)
75 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010076 // Check galera status
77 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
78 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
79 // Install haproxy
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010080 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010081 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
82 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
83 // Install memcached
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010084 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010085}
86
87
88def installOpenstackMkControl(master) {
89 def salt = new com.mirantis.mk.Salt()
90 // setup keystone service
91 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010092 salt.enforceState(master, 'ctl01*', 'keystone.server', true)
93 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010094 // populate keystone services/tenants/roles/users
Tomáš Kukrál926e6332017-03-02 09:23:03 +010095
96 // keystone:client must be called locally
97 salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'])
98
Jakub Josef79ecec32017-02-17 14:36:28 +010099 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'])
100 // Install glance and ensure glusterfs clusters
101 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100102 salt.enforceState(master, 'ctl01*', 'glance.server', true)
103 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
104 salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100105 // Update fernet tokens before doing request on keystone server
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100106 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100107 // Check glance service
108 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'])
109 // Install and check nova service
110 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100111 salt.enforceState(master, 'ctl01*', 'nova', true)
112 salt.enforceState(master, 'I@nova:controller', 'nova', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100113 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'])
114 // Install and check cinder service
115 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100116 salt.enforceState(master, 'ctl01*', 'cinder', true)
117 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100118 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'])
119 // Install neutron service
120 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100121 salt.enforceState(master, 'ctl01*', 'neutron', true)
122 salt.enforceState(master, 'I@neutron:server', 'neutron', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100123 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'])
124 // Install heat service
125 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100126 salt.enforceState(master, 'ctl01*', 'heat', true)
127 salt.enforceState(master, 'I@heat:server', 'heat', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100128 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'])
129 // Install horizon dashboard
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100130 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
131 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100132}
133
134
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100135def installOpenstackMkNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100136 def salt = new com.mirantis.mk.Salt()
137 // Install opencontrail database services
138 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100139 salt.enforceState(master, 'ntw01*', 'opencontrail.database', true)
140 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100141 // Install opencontrail control services
142 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100143 salt.enforceState(master, 'ntw01*', 'opencontrail', true)
144 salt.enforceState(master, 'I@opencontrail:control', 'opencontrail', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100145
Jakub Josef79ecec32017-02-17 14:36:28 +0100146 // Provision opencontrail control services
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100147 if (physical.equals("false")) {
148 salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl01 --host_ip 172.16.10.101 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'])
149 salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl02 --host_ip 172.16.10.102 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'])
150 salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl03 --host_ip 172.16.10.103 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'])
151 }
152
Jakub Josef79ecec32017-02-17 14:36:28 +0100153 // Test opencontrail
154 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'])
155 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
156 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
157}
158
159
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100160def installOpenstackMkCompute(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100161 def salt = new com.mirantis.mk.Salt()
162 // Configure compute nodes
163 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
164 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100165
Jakub Josef79ecec32017-02-17 14:36:28 +0100166 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100167 if (physical.equals("false")) {
168 salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp01 --host_ip 172.16.10.105 --api_server_ip 172.16.10.254 --oper add --admin_user admin --admin_password workshop --admin_tenant_name admin'])
169 }
170
Jakub Josef79ecec32017-02-17 14:36:28 +0100171 salt.runSaltProcessStep(master, 'I@nova:compute', 'system.reboot')
172}
173
174
175def installOpenstackMcpInfra(master) {
176 def salt = new com.mirantis.mk.Salt()
177 // Comment nameserver
178 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
179 // Install glusterfs
180 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
181 // Install keepalived
182 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived'])
183 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
184 // Check the keepalived VIPs
185 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
186 // Setup glusterfs
187 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
188 salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
189 salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
190 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
191 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
192 // Install haproxy
193 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
194 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
195 // Install docker
196 salt.runSaltProcessStep(master, 'I@docker:host', 'state.sls', ['docker.host'])
197 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
198 // Install bird
199 salt.runSaltProcessStep(master, 'I@bird:server', 'state.sls', ['bird'])
200 // Install etcd
Tomáš Kukrálc59f4c52017-03-10 23:03:48 +0100201 salt.runSaltProcessStep(master, 'I@etcd:server', 'state.sls', ['salt.minion.cert,etcd.server.service'])
Jakub Josef79ecec32017-02-17 14:36:28 +0100202 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
203}
204
205
206def installOpenstackMcpControl(master) {
207 def salt = new com.mirantis.mk.Salt()
208 // Install Kubernetes pool and Calico
209 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
210 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
211
212 // Setup etcd server
213 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
214
215 // Run k8s without master.setup
216 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
217
218 // Run k8s master setup
219 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
220
221 // Revert comment nameserver
222 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
223
224 // Set route
225 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
226
227 // Restart kubelet
228 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
229}
230
231
232def installOpenstackMcpCompute(master) {
233 def salt = new com.mirantis.mk.Salt();
234 // Install opencontrail
235 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
236 // Reboot compute nodes
237 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
238}
239
240
241def installStacklightControl(master) {
242 def salt = new com.mirantis.mk.Salt();
243 salt.runSaltProcessStep(master, 'I@elasticsearch:server', 'state.sls', ['elasticsearch.server'])
244 salt.runSaltProcessStep(master, 'I@influxdb:server', 'state.sls', ['influxdb'])
245 salt.runSaltProcessStep(master, 'I@kibana:server', 'state.sls', ['kibana.server'])
246 salt.runSaltProcessStep(master, 'I@grafana:server', 'state.sls', ['grafana'])
247 salt.runSaltProcessStep(master, 'I@nagios:server', 'state.sls', ['nagios'])
248 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'state.sls', ['elasticsearch.client'])
249 salt.runSaltProcessStep(master, 'I@kibana:client', 'state.sls', ['kibana.client'])
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100250}