blob: 069442e78b91dfc144efe6155fbc4d9645beac43 [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'])
31 salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['libvirt'])
32 salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['salt.control'])
33}
Jakub Josef79ecec32017-02-17 14:36:28 +010034
35def installOpenstackMkInfra(master) {
36 def salt = new com.mirantis.mk.Salt()
37 // Install keepaliveds
38 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
39 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived'])
40 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
41 // Check the keepalived VIPs
42 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
43 // Install glusterfs
44 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
45 //runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
46 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
47 salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
48 salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
49 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
50 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
51 // Install rabbitmq
52 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'state.sls', ['rabbitmq'])
53 // Check the rabbitmq status
54 salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
55 // Install galera
56 salt.runSaltProcessStep(master, 'I@galera:master', 'state.sls', ['galera'])
57 salt.runSaltProcessStep(master, 'I@galera:slave', 'state.sls', ['galera'])
58 // Check galera status
59 salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status')
60 salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status')
61 // Install haproxy
62 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
63 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
64 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
65 // Install memcached
66 salt.runSaltProcessStep(master, 'I@memcached:server', 'state.sls', ['memcached'])
67}
68
69
70def installOpenstackMkControl(master) {
71 def salt = new com.mirantis.mk.Salt()
72 // setup keystone service
73 //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
74 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keystone.server'])
75 salt.runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'])
76 // populate keystone services/tenants/roles/users
77 salt.runSaltProcessStep(master, 'I@keystone:client', 'state.sls', ['keystone.client'])
78 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'])
79 // Install glance and ensure glusterfs clusters
80 //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
81 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glance.server'])
82 salt.runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'])
83 salt.runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glusterfs.client'])
84 // Update fernet tokens before doing request on keystone server
85 salt.runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'])
86 // Check glance service
87 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'])
88 // Install and check nova service
89 //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1)
90 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['nova'])
91 salt.runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'])
92 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'])
93 // Install and check cinder service
94 //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
95 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['cinder'])
96 salt.runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'])
97 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'])
98 // Install neutron service
99 //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1)
100 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['neutron'])
101 salt.runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'])
102 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'])
103 // Install heat service
104 //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1)
105 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['heat'])
106 salt.runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'])
107 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'])
108 // Install horizon dashboard
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100109 salt.runSaltProcessStep(master, 'I@horizon:server', 'state.sls', ['horizon'])
110 salt.runSaltProcessStep(master, 'I@nginx:server', 'state.sls', ['nginx'])
Jakub Josef79ecec32017-02-17 14:36:28 +0100111}
112
113
114def installOpenstackMkNetwork(master) {
115 def salt = new com.mirantis.mk.Salt()
116 // Install opencontrail database services
117 //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
118 salt.runSaltProcessStep(master, 'ntw01*', 'state.sls', ['opencontrail.database'])
119 salt.runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'])
120 // Install opencontrail control services
121 //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
122 salt.runSaltProcessStep(master, 'ntw01*', 'state.sls', ['opencontrail'])
123 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'])
124 // Provision opencontrail control services
125 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'])
126 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'])
127 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'])
128 // Test opencontrail
129 salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'])
130 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
131 salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
132}
133
134
135def installOpenstackMkCompute(master) {
136 def salt = new com.mirantis.mk.Salt()
137 // Configure compute nodes
138 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
139 salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply')
140 // Provision opencontrail virtual routers
141 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'])
142 salt.runSaltProcessStep(master, 'I@nova:compute', 'system.reboot')
143}
144
145
146def installOpenstackMcpInfra(master) {
147 def salt = new com.mirantis.mk.Salt()
148 // Comment nameserver
149 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"])
150 // Install glusterfs
151 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
152 // Install keepalived
153 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived'])
154 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
155 // Check the keepalived VIPs
156 salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
157 // Setup glusterfs
158 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
159 salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
160 salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
161 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
162 salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
163 // Install haproxy
164 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
165 salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy'])
166 // Install docker
167 salt.runSaltProcessStep(master, 'I@docker:host', 'state.sls', ['docker.host'])
168 salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps'])
169 // Install bird
170 salt.runSaltProcessStep(master, 'I@bird:server', 'state.sls', ['bird'])
171 // Install etcd
172 salt.runSaltProcessStep(master, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
173 salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
174}
175
176
177def installOpenstackMcpControl(master) {
178 def salt = new com.mirantis.mk.Salt()
179 // Install Kubernetes pool and Calico
180 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
181 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
182
183 // Setup etcd server
184 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
185
186 // Run k8s without master.setup
187 salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
188
189 // Run k8s master setup
190 salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
191
192 // Revert comment nameserver
193 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"])
194
195 // Set route
196 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
197
198 // Restart kubelet
199 salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
200}
201
202
203def installOpenstackMcpCompute(master) {
204 def salt = new com.mirantis.mk.Salt();
205 // Install opencontrail
206 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail'])
207 // Reboot compute nodes
208 salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot')
209}
210
211
212def installStacklightControl(master) {
213 def salt = new com.mirantis.mk.Salt();
214 salt.runSaltProcessStep(master, 'I@elasticsearch:server', 'state.sls', ['elasticsearch.server'])
215 salt.runSaltProcessStep(master, 'I@influxdb:server', 'state.sls', ['influxdb'])
216 salt.runSaltProcessStep(master, 'I@kibana:server', 'state.sls', ['kibana.server'])
217 salt.runSaltProcessStep(master, 'I@grafana:server', 'state.sls', ['grafana'])
218 salt.runSaltProcessStep(master, 'I@nagios:server', 'state.sls', ['nagios'])
219 salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'state.sls', ['elasticsearch.client'])
220 salt.runSaltProcessStep(master, 'I@kibana:client', 'state.sls', ['kibana.client'])
Tomáš Kukrálf06ca0f2017-02-27 15:18:50 +0100221}