blob: 609e2011b6ab21b182964f2df40592d4e3e2f63e [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'])
20 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar')
21 salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all')
22 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')
38 salt.runSaltProcessStep(master, '* and not kvm*', 'state.sls', ['linux,openssh,salt.minion,ntp'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010039
Tomáš Kukrál8d2be5a2017-02-28 11:22:29 +010040}
Jakub Josef79ecec32017-02-17 14:36:28 +010041
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010042def installOpenstackMkInfra(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +010043 def salt = new com.mirantis.mk.Salt()
44 // Install keepaliveds
45 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010046 salt.enforceState(master, 'ctl01*', 'keepalived', true)
47 salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010048 // Check the keepalived VIPs
49 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
50 // Install glusterfs
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010051 salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010052
Jakub Josef79ecec32017-02-17 14:36:28 +010053 //runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010054 if (physical.equals("false")) {
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010055 salt.enforceState(master, 'ctl01*', 'glusterfs.server.setup', true)
56 salt.enforceState(master, 'ctl02*', 'glusterfs.server.setup', true)
57 salt.enforceState(master, 'ctl03*', 'glusterfs.server.setup', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010058 } else {
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010059 salt.enforceState(master, 'kvm01*', 'glusterfs.server.setup', true)
60 salt.enforceState(master, 'kvm02*', 'glusterfs.server.setup', true)
61 salt.enforceState(master, 'kvm03*', 'glusterfs.server.setup', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010062 }
Jakub Josef79ecec32017-02-17 14:36:28 +010063 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
64 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
Tomáš Kukrálb8e97112017-03-01 16:03:16 +010065
Jakub Josef79ecec32017-02-17 14:36:28 +010066 // Install rabbitmq
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010067 salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010068 // Check the rabbitmq status
69 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
70 // Install galera
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010071 salt.enforceState(master, 'I@galera:master', 'galera', true)
72 salt.enforceState(master, 'I@galera:slave', 'galera', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010073 // Check galera status
74 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
75 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
76 // Install haproxy
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010077 salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010078 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
79 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
80 // Install memcached
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010081 salt.enforceState(master, 'I@memcached:server', 'memcached', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010082}
83
84
85def installOpenstackMkControl(master) {
86 def salt = new com.mirantis.mk.Salt()
87 // setup keystone service
88 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010089 salt.enforceState(master, 'ctl01*', 'keystone.server', true)
90 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010091 // populate keystone services/tenants/roles/users
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010092 salt.enforceState(master, 'I@keystone:client', 'keystone.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010093 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'])
94 // Install glance and ensure glusterfs clusters
95 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +010096 salt.enforceState(master, 'ctl01*', 'glance.server', true)
97 salt.enforceState(master, 'I@glance:server', 'glance.server', true)
98 salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true)
Jakub Josef79ecec32017-02-17 14:36:28 +010099 // Update fernet tokens before doing request on keystone server
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100100 salt.enforceState(master, 'I@keystone:server', 'keystone.server', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100101 // Check glance service
102 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'])
103 // Install and check nova service
104 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100105 salt.enforceState(master, 'ctl01*', 'nova', true)
106 salt.enforceState(master, 'I@nova:controller', 'nova', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100107 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'])
108 // Install and check cinder service
109 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100110 salt.enforceState(master, 'ctl01*', 'cinder', true)
111 salt.enforceState(master, 'I@cinder:controller', 'cinder', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100112 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'])
113 // Install neutron service
114 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100115 salt.enforceState(master, 'ctl01*', 'neutron', true)
116 salt.enforceState(master, 'I@neutron:server', 'neutron', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100117 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'])
118 // Install heat service
119 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100120 salt.enforceState(master, 'ctl01*', 'heat', true)
121 salt.enforceState(master, 'I@heat:server', 'heat', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100122 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'])
123 // Install horizon dashboard
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100124 salt.enforceState(master, 'I@horizon:server', 'horizon', true)
125 salt.enforceState(master, 'I@nginx:server', 'nginx', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100126}
127
128
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100129def installOpenstackMkNetwork(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100130 def salt = new com.mirantis.mk.Salt()
131 // Install opencontrail database services
132 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100133 salt.enforceState(master, 'ntw01*', 'opencontrail.database', true)
134 salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100135 // Install opencontrail control services
136 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
Tomáš Kukrál0abdde52017-03-01 21:57:23 +0100137 salt.enforceState(master, 'ntw01*', 'opencontrail', true)
138 salt.enforceState(master, 'I@opencontrail:control', 'opencontrail', true)
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100139
Jakub Josef79ecec32017-02-17 14:36:28 +0100140 // Provision opencontrail control services
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100141 if (physical.equals("false")) {
142 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'])
143 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'])
144 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'])
145 }
146
Jakub Josef79ecec32017-02-17 14:36:28 +0100147 // Test opencontrail
148 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'])
149 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
150 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
151}
152
153
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100154def installOpenstackMkCompute(master, physical = "false") {
Jakub Josef79ecec32017-02-17 14:36:28 +0100155 def salt = new com.mirantis.mk.Salt()
156 // Configure compute nodes
157 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
158 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100159
Jakub Josef79ecec32017-02-17 14:36:28 +0100160 // Provision opencontrail virtual routers
Tomáš Kukrálb8e97112017-03-01 16:03:16 +0100161 if (physical.equals("false")) {
162 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'])
163 }
164
Jakub Josef79ecec32017-02-17 14:36:28 +0100165 salt.runSaltProcessStep(master, 'I@nova:compute', 'system.reboot')
166}
167
168
169def installOpenstackMcpInfra(master) {
170 def salt = new com.mirantis.mk.Salt()
171 // Comment nameserver
172 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"])
173 // Install glusterfs
174 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
175 // Install keepalived
176 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived'])
177 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
178 // Check the keepalived VIPs
179 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
180 // Setup glusterfs
181 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
182 salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
183 salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
184 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
185 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
186 // Install haproxy
187 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
188 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
189 // Install docker
190 salt.runSaltProcessStep(master, 'I@docker:host', 'state.sls', ['docker.host'])
191 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
192 // Install bird
193 salt.runSaltProcessStep(master, 'I@bird:server', 'state.sls', ['bird'])
194 // Install etcd
195 salt.runSaltProcessStep(master, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
196 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
197}
198
199
200def installOpenstackMcpControl(master) {
201 def salt = new com.mirantis.mk.Salt()
202 // Install Kubernetes pool and Calico
203 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
204 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
205
206 // Setup etcd server
207 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
208
209 // Run k8s without master.setup
210 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
211
212 // Run k8s master setup
213 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
214
215 // Revert comment nameserver
216 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"])
217
218 // Set route
219 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
220
221 // Restart kubelet
222 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
223}
224
225
226def installOpenstackMcpCompute(master) {
227 def salt = new com.mirantis.mk.Salt();
228 // Install opencontrail
229 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
230 // Reboot compute nodes
231 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
232}
233
234
235def installStacklightControl(master) {
236 def salt = new com.mirantis.mk.Salt();
237 salt.runSaltProcessStep(master, 'I@elasticsearch:server', 'state.sls', ['elasticsearch.server'])
238 salt.runSaltProcessStep(master, 'I@influxdb:server', 'state.sls', ['influxdb'])
239 salt.runSaltProcessStep(master, 'I@kibana:server', 'state.sls', ['kibana.server'])
240 salt.runSaltProcessStep(master, 'I@grafana:server', 'state.sls', ['grafana'])
241 salt.runSaltProcessStep(master, 'I@nagios:server', 'state.sls', ['nagios'])
242 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'state.sls', ['elasticsearch.client'])
243 salt.runSaltProcessStep(master, 'I@kibana:client', 'state.sls', ['kibana.client'])
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100244}