blob: 382aaa5e7d185da7bac4dd04319115b44eedb21c [file] [log] [blame]
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01001/**
2 *
3 * Launch heat stack with basic k8s
4 * Flow parameters:
5 * STACK_TYPE Orchestration engine: heat, ''
6 * INSTALL What should be installed (k8s, openstack, ...)
Tomáš Kukrál55357d02017-02-28 22:56:45 +01007 * TEST What should be tested (k8s, openstack, ...)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01008 *
9 * Expected parameters:
10 *
11 * required for STACK_TYPE=heat
12 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
13 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
14 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
15 * HEAT_STACK_TEMPLATE Heat stack HOT template
16 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
17 * HEAT_STACK_ZONE Heat stack availability zone
18 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
19 * HEAT_STACK_DELETE Delete Heat stack when finished (bool)
20 * HEAT_STACK_CLEANUP_JOB Name of job for deleting Heat stack
21 * HEAT_STACK_REUSE Reuse Heat stack (don't create one)
22 * OPENSTACK_API_URL OpenStack API address
23 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
24 * OPENSTACK_API_PROJECT OpenStack project to connect to
25 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
26 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
27 *
28 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
29 *
30 * required for STACK_TYPE=NONE or empty string
31 * SALT_MASTER_URL URL of Salt-API
32
33 * K8S_API_SERVER Kubernetes API address
34 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
35 *
36 */
37
38git = new com.mirantis.mk.Git()
39openstack = new com.mirantis.mk.Openstack()
40salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010041
Tomáš Kukrále80680a2017-03-02 16:34:35 +010042
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010043timestamps {
44 node {
Tomáš Kukrála18de112017-03-02 13:57:47 +010045 try {
Tomáš Kukrále80680a2017-03-02 16:34:35 +010046
47
Tomáš Kukrála18de112017-03-02 13:57:47 +010048 //
49 // Prepare machines
50 //
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010051
Tomáš Kukrála18de112017-03-02 13:57:47 +010052 stage ('Create infrastructure') {
53 if (STACK_TYPE == 'heat') {
54 // value defaults
55 def openstackCloud
56 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
57 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010058
Tomáš Kukrála18de112017-03-02 13:57:47 +010059 if (HEAT_STACK_NAME == '') {
60 HEAT_STACK_NAME = BUILD_TAG
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010061 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010062
Tomáš Kukrálcbabec42017-03-02 16:24:04 +010063 // set description
Tomáš Kukrálaeb5c922017-03-02 17:00:48 +010064 currentBuild.description = "${HEAT_STACK_NAME}"
Tomáš Kukrálcbabec42017-03-02 16:24:04 +010065
Tomáš Kukrála18de112017-03-02 13:57:47 +010066 // get templates
67 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
68
69 // create openstack env
70 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
71 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
72 openstack.getKeystoneToken(openstackCloud, openstackEnv)
73
74 // launch stack
75 if (HEAT_STACK_REUSE == 'false') {
76 stage('Launch new Heat stack') {
77 // create stack
78 envParams = [
79 'instance_zone': HEAT_STACK_ZONE,
80 'public_net': HEAT_STACK_PUBLIC_NET
81 ]
82 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
83 }
84 }
85
86 // get SALT_MASTER_URL
87 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
Tomáš Kukrálaeb5c922017-03-02 17:00:48 +010088 currentBuild.description = "${HEAT_STACK_NAME}: ${saltMasterHost}"
Tomáš Kukrála18de112017-03-02 13:57:47 +010089 SALT_MASTER_URL = "http://${saltMasterHost}:8088"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010090 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010091 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010092
Tomáš Kukrála18de112017-03-02 13:57:47 +010093 //
94 // Connect to Salt master
95 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010096
Tomáš Kukrála18de112017-03-02 13:57:47 +010097 def saltMaster
98 stage('Connect to Salt API') {
99 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
100 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100101
Tomáš Kukrála18de112017-03-02 13:57:47 +0100102 //
103 // Install
104 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100105
Tomáš Kukrála18de112017-03-02 13:57:47 +0100106 if (INSTALL.toLowerCase().contains('core')) {
107 stage('Install core infrastructure') {
108 // salt.master, reclass
109 // refresh_pillar
110 // sync_all
111 // linux,openssh,salt.minion.ntp
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100112
Tomáš Kukrála18de112017-03-02 13:57:47 +0100113 //orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100114 salt.enforceState(saltMaster, 'I@salt:master', ['salt.master', 'reclass'], true)
115 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', null, true)
116 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', null, true)
117 salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100118
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100119
Tomáš Kukrála18de112017-03-02 13:57:47 +0100120 if (INSTALL.toLowerCase().contains('kvm')) {
121 //orchestrate.installInfraKvm(saltMaster)
122 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar')
123 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all')
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100124
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100125 salt.enforceState(saltMaster, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100126 salt.enforceState(saltMaster, 'I@salt:control', 'libvirt', true)
127 salt.enforceState(saltMaster, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100128
Tomáš Kukrála18de112017-03-02 13:57:47 +0100129 sleep(300)
130
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100131 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.refresh_pillar', null, true)
132 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.sync_all', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100133
134 // workaround - install apt-transport-https
135 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'pkg.install', ['apt-transport-https refresh=True'])
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100136 salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100137 }
138
139 //orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100140 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['salt-key'], null, true)
141 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'test.version', null, true)
142 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true)
143 salt.runSaltProcessStep(saltMaster, 'I@reclass:storage', 'reclass.inventory', null, true)
144 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'state.show_top', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100145 }
146 }
147
148 // install k8s
149 if (INSTALL.toLowerCase().contains('k8s')) {
150 stage('Install Kubernetes infra') {
151 //orchestrate.installOpenstackMcpInfra(saltMaster)
152
153 // Comment nameserver
154 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
155
156 // Install glusterfs
157 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
158
159 // Install keepalived
160 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['keepalived'])
161 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
162
163 // Check the keepalived VIPs
164 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
165
166 // Setup glusterfs
167 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
168 salt.runSaltProcessStep(saltMaster, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
169 salt.runSaltProcessStep(saltMaster, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
170 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
171 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
172
173 // Install haproxy
174 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
175 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'])
176
177 // Install docker
178 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host'])
179 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps'])
180
181 // Install bird
182 salt.runSaltProcessStep(saltMaster, 'I@bird:server', 'state.sls', ['bird'])
183
184 // Install etcd
185 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
186 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
187
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100188 }
189
Tomáš Kukrála18de112017-03-02 13:57:47 +0100190 stage('Install Kubernetes control') {
191 //orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál06c27a92017-03-01 16:21:46 +0100192
Tomáš Kukrála18de112017-03-02 13:57:47 +0100193 // Install Kubernetes pool and Calico
194 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
195 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100196
Tomáš Kukrála18de112017-03-02 13:57:47 +0100197 // Setup etcd server
198 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100199
Tomáš Kukrála18de112017-03-02 13:57:47 +0100200 // Run k8s without master.setup
201 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100202
Tomáš Kukrála18de112017-03-02 13:57:47 +0100203 // Run k8s master setup
204 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100205
Tomáš Kukrála18de112017-03-02 13:57:47 +0100206 // Revert comment nameserver
207 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100208
Tomáš Kukrála18de112017-03-02 13:57:47 +0100209 // Set route
210 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100211
Tomáš Kukrála18de112017-03-02 13:57:47 +0100212 // Restart kubelet
213 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100214 }
215
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100216 }
217
Tomáš Kukrála18de112017-03-02 13:57:47 +0100218 // install openstack
219 if (INSTALL.toLowerCase().contains('openstack')) {
220 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100221
Tomáš Kukrála18de112017-03-02 13:57:47 +0100222 stage('Install OpenStack infra') {
223 //orchestrate.installOpenstackMkInfra(saltMaster, physical)
224
225 // Install keepaliveds
226 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
227 salt.enforceState(saltMaster, 'ctl01*', 'keepalived', true)
228 salt.enforceState(saltMaster, 'I@keepalived:cluster', 'keepalived', true)
229
230 // Check the keepalived VIPs
231 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
232
233 // Install glusterfs
234 salt.enforceState(saltMaster, 'I@glusterfs:server', 'glusterfs.server.service', true)
235
236 //runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
237 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100238 salt.enforceState(saltMaster, 'kvm01*', 'glusterfs.server.setup', true)
239 salt.enforceState(saltMaster, 'kvm02*', 'glusterfs.server.setup', true)
240 salt.enforceState(saltMaster, 'kvm03*', 'glusterfs.server.setup', true)
Tomáš Kukrálbad54bb2017-03-02 15:46:20 +0100241 } else {
242 salt.enforceState(saltMaster, 'ctl01*', 'glusterfs.server.setup', true)
243 salt.enforceState(saltMaster, 'ctl02*', 'glusterfs.server.setup', true)
244 salt.enforceState(saltMaster, 'ctl03*', 'glusterfs.server.setup', true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100245 }
246
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100247 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
248 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100249
250 // Install rabbitmq
251 salt.enforceState(saltMaster, 'I@rabbitmq:server', 'rabbitmq', true)
252
253 // Check the rabbitmq status
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100254 salt.runSaltProcessStep(saltMaster, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100255
256 // Install galera
257 salt.enforceState(saltMaster, 'I@galera:master', 'galera', true)
258 salt.enforceState(saltMaster, 'I@galera:slave', 'galera', true)
259
260 // Check galera status
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100261 salt.runSaltProcessStep(saltMaster, 'I@galera:master', 'mysql.status')
262 salt.runSaltProcessStep(saltMaster, 'I@galera:slave', 'mysql.status')
Tomáš Kukrála18de112017-03-02 13:57:47 +0100263
264 // Install haproxy
265 salt.enforceState(saltMaster, 'I@haproxy:proxy', 'haproxy', true)
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100266 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'])
267 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100268
269 // Install memcached
270 salt.enforceState(saltMaster, 'I@memcached:server', 'memcached', true)
271
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100272 }
273
Tomáš Kukrála18de112017-03-02 13:57:47 +0100274 stage('Install OpenStack control') {
275 //orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100276
Tomáš Kukrála18de112017-03-02 13:57:47 +0100277 // setup keystone service
278 //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
279 salt.enforceState(saltMaster, 'ctl01*', 'keystone.server', true)
280 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
281 // populate keystone services/tenants/roles/users
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100282
Tomáš Kukrála18de112017-03-02 13:57:47 +0100283 // keystone:client must be called locally
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100284 salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
285 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100286
287 // Install glance and ensure glusterfs clusters
288 //runSaltProcessStep(saltMaster, 'I@glance:server', 'state.sls', ['glance.server'], 1)
289 salt.enforceState(saltMaster, 'ctl01*', 'glance.server', true)
290 salt.enforceState(saltMaster, 'I@glance:server', 'glance.server', true)
291 salt.enforceState(saltMaster, 'I@glance:server', 'glusterfs.client', true)
292
293 // Update fernet tokens before doing request on keystone server
294 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
295
296 // Check glance service
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100297 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100298
299 // Install and check nova service
300 //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1)
301 salt.enforceState(saltMaster, 'ctl01*', 'nova', true)
302 salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100303 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100304
305 // Install and check cinder service
306 //runSaltProcessStep(saltMaster, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
307 salt.enforceState(saltMaster, 'ctl01*', 'cinder', true)
308 salt.enforceState(saltMaster, 'I@cinder:controller', 'cinder', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100309 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100310
311 // Install neutron service
312 //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Tomáš Kukrál575e38a2017-03-02 17:12:45 +0100313 if (INSTALL.toLowerCase().contains('kvm')) {
314 salt.enforceState(saltMaster, 'ntw01*', 'neutron', true)
315 } else {
316 salt.enforceState(saltMaster, 'ctl01*', 'neutron', true)
317 }
318
Tomáš Kukrála18de112017-03-02 13:57:47 +0100319 salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100320 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100321
322 // Install heat service
323 //runSaltProcessStep(saltMaster, 'I@heat:server', 'state.sls', ['heat'], 1)
324 salt.enforceState(saltMaster, 'ctl01*', 'heat', true)
325 salt.enforceState(saltMaster, 'I@heat:server', 'heat', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100326 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100327
328 // Install horizon dashboard
329 salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true)
330 salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true)
331
332 }
333
334 stage('Install OpenStack network') {
335 //orchestrate.installOpenstackMkNetwork(saltMaster, physical)
336
337 // Install opencontrail database services
338 //runSaltProcessStep(saltMaster, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
339 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail.database', true)
340 salt.enforceState(saltMaster, 'I@opencontrail:database', 'opencontrail.database', true)
341
342 // Install opencontrail control services
343 //runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
344 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail', true)
345 salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail', true)
346
347 // Provision opencontrail control services
348 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrál575e38a2017-03-02 17:12:45 +0100349 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw01 --host_ip 10.167.4.21 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true)
350 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw02 --host_ip 10.167.4.22 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true)
351 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw03 --host_ip 10.167.4.23 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true)
352 } else {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100353 salt.runSaltProcessStep(saltMaster, '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'], null, true)
354 salt.runSaltProcessStep(saltMaster, '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'], null, true)
355 salt.runSaltProcessStep(saltMaster, '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'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100356 }
357
358 // Test opencontrail
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100359 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
360 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'], null, true)
361 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100362 }
363
364 stage('Install OpenStack compute') {
365 //orchestrate.installOpenstackMkCompute(saltMaster, physical)
366 // Configure compute nodes
Tomáš Kukrálda26d902017-03-02 22:19:00 +0100367 retry(2) {
Tomáš Kukrál02cda9f2017-03-02 22:32:57 +0100368 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', [], null, true)
Tomáš Kukrálda26d902017-03-02 22:19:00 +0100369 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100370
371 // Provision opencontrail virtual routers
372 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrál834fe212017-03-02 22:50:49 +0100373 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp001 --host_ip 10.167.4.101 --api_server_ip 10.167.4.20 --oper add --admin_user admin --admin_password password --admin_tenant_name admin'], null, true)
Tomáš Kukrál575e38a2017-03-02 17:12:45 +0100374 } else {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100375 salt.runSaltProcessStep(saltMaster, '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'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100376 }
377
Tomáš Kukrálc39610c2017-03-02 22:56:06 +0100378 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'system.reboot', [], null, true)
379 sleep(30)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100380 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100381 }
382
Tomáš Kukrála18de112017-03-02 13:57:47 +0100383 //
384 // Test
385 //
386
387 if (TEST.toLowerCase().contains('k8s')) {
388 stage('Run k8s bootstrap tests') {
389 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
390 }
391
392 stage('Run k8s conformance e2e tests') {
393 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
394 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100395 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100396
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100397
Tomáš Kukrála18de112017-03-02 13:57:47 +0100398 } catch (Throwable e) {
399 currentBuild.result = 'FAILURE'
400 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100401 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100402
Tomáš Kukrála18de112017-03-02 13:57:47 +0100403 //
404 // Clean
405 //
406
407 if (HEAT_STACK_DELETE == 'true' && STACK_TYPE == 'heat') {
408 stage('Trigger cleanup job') {
409 build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
410 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100411 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100412 }
413 }
414}