blob: 7c570ef3951d0a305dec2a50110519085c96e371 [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)
Tomáš Kukrál01f284a2017-03-02 23:14:20 +0100115 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
116 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', [], null, true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100117 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)
Tomáš Kukrál01f284a2017-03-02 23:14:20 +0100122 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true)
123 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', [], null, true)
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ál01f284a2017-03-02 23:14:20 +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
Tomáš Kukrál5c837882017-03-03 00:54:13 +0100135 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'cmd.run', ['apt-get update -y && apt-get install -y apt-transport-https'], null, true)
Tomáš Kukrál677b4232017-03-02 23:31:12 +0100136 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'pkg.install', ['apt-transport-https', 'refresh=True'], null, true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100137 salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100138 }
139
140 //orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100141 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['salt-key'], null, true)
Tomáš Kukrál01f284a2017-03-02 23:14:20 +0100142 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'test.version', [], null, true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100143 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true)
Tomáš Kukrál01f284a2017-03-02 23:14:20 +0100144 salt.runSaltProcessStep(saltMaster, 'I@reclass:storage', 'reclass.inventory', [], null, true)
145 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'state.show_top', [], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100146 }
147 }
148
149 // install k8s
150 if (INSTALL.toLowerCase().contains('k8s')) {
151 stage('Install Kubernetes infra') {
152 //orchestrate.installOpenstackMcpInfra(saltMaster)
153
154 // Comment nameserver
155 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"])
156
157 // Install glusterfs
158 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
159
160 // Install keepalived
161 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['keepalived'])
162 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
163
164 // Check the keepalived VIPs
165 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
166
167 // Setup glusterfs
168 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
169 salt.runSaltProcessStep(saltMaster, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
170 salt.runSaltProcessStep(saltMaster, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
171 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
172 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
173
174 // Install haproxy
175 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
176 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'])
177
178 // Install docker
179 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host'])
180 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps'])
181
182 // Install bird
183 salt.runSaltProcessStep(saltMaster, 'I@bird:server', 'state.sls', ['bird'])
184
185 // Install etcd
186 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
187 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
188
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100189 }
190
Tomáš Kukrála18de112017-03-02 13:57:47 +0100191 stage('Install Kubernetes control') {
192 //orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál06c27a92017-03-01 16:21:46 +0100193
Tomáš Kukrála18de112017-03-02 13:57:47 +0100194 // Install Kubernetes pool and Calico
195 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
196 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100197
Tomáš Kukrála18de112017-03-02 13:57:47 +0100198 // Setup etcd server
199 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100200
Tomáš Kukrála18de112017-03-02 13:57:47 +0100201 // Run k8s without master.setup
202 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100203
Tomáš Kukrála18de112017-03-02 13:57:47 +0100204 // Run k8s master setup
205 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100206
Tomáš Kukrála18de112017-03-02 13:57:47 +0100207 // Revert comment nameserver
208 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 +0100209
Tomáš Kukrála18de112017-03-02 13:57:47 +0100210 // Set route
211 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 +0100212
Tomáš Kukrála18de112017-03-02 13:57:47 +0100213 // Restart kubelet
214 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100215 }
216
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100217 }
218
Tomáš Kukrála18de112017-03-02 13:57:47 +0100219 // install openstack
220 if (INSTALL.toLowerCase().contains('openstack')) {
221 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100222
Tomáš Kukrála18de112017-03-02 13:57:47 +0100223 stage('Install OpenStack infra') {
224 //orchestrate.installOpenstackMkInfra(saltMaster, physical)
225
226 // Install keepaliveds
227 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
228 salt.enforceState(saltMaster, 'ctl01*', 'keepalived', true)
229 salt.enforceState(saltMaster, 'I@keepalived:cluster', 'keepalived', true)
230
231 // Check the keepalived VIPs
232 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
233
234 // Install glusterfs
235 salt.enforceState(saltMaster, 'I@glusterfs:server', 'glusterfs.server.service', true)
236
237 //runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
238 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100239 salt.enforceState(saltMaster, 'kvm01*', 'glusterfs.server.setup', true)
240 salt.enforceState(saltMaster, 'kvm02*', 'glusterfs.server.setup', true)
241 salt.enforceState(saltMaster, 'kvm03*', 'glusterfs.server.setup', true)
Tomáš Kukrálbad54bb2017-03-02 15:46:20 +0100242 } else {
243 salt.enforceState(saltMaster, 'ctl01*', 'glusterfs.server.setup', true)
244 salt.enforceState(saltMaster, 'ctl02*', 'glusterfs.server.setup', true)
245 salt.enforceState(saltMaster, 'ctl03*', 'glusterfs.server.setup', true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100246 }
247
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100248 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
249 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100250
251 // Install rabbitmq
252 salt.enforceState(saltMaster, 'I@rabbitmq:server', 'rabbitmq', true)
253
254 // Check the rabbitmq status
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100255 salt.runSaltProcessStep(saltMaster, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100256
257 // Install galera
258 salt.enforceState(saltMaster, 'I@galera:master', 'galera', true)
259 salt.enforceState(saltMaster, 'I@galera:slave', 'galera', true)
260
261 // Check galera status
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100262 salt.runSaltProcessStep(saltMaster, 'I@galera:master', 'mysql.status')
263 salt.runSaltProcessStep(saltMaster, 'I@galera:slave', 'mysql.status')
Tomáš Kukrála18de112017-03-02 13:57:47 +0100264
265 // Install haproxy
266 salt.enforceState(saltMaster, 'I@haproxy:proxy', 'haproxy', true)
Ales Komarek96ff9ed2017-03-02 18:37:51 +0100267 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'])
268 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.restart', ['rsyslog'])
Tomáš Kukrála18de112017-03-02 13:57:47 +0100269
270 // Install memcached
271 salt.enforceState(saltMaster, 'I@memcached:server', 'memcached', true)
272
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100273 }
274
Tomáš Kukrála18de112017-03-02 13:57:47 +0100275 stage('Install OpenStack control') {
276 //orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100277
Tomáš Kukrála18de112017-03-02 13:57:47 +0100278 // setup keystone service
279 //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
280 salt.enforceState(saltMaster, 'ctl01*', 'keystone.server', true)
281 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
282 // populate keystone services/tenants/roles/users
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100283
Tomáš Kukrála18de112017-03-02 13:57:47 +0100284 // keystone:client must be called locally
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100285 salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
286 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100287
288 // Install glance and ensure glusterfs clusters
289 //runSaltProcessStep(saltMaster, 'I@glance:server', 'state.sls', ['glance.server'], 1)
290 salt.enforceState(saltMaster, 'ctl01*', 'glance.server', true)
291 salt.enforceState(saltMaster, 'I@glance:server', 'glance.server', true)
292 salt.enforceState(saltMaster, 'I@glance:server', 'glusterfs.client', true)
293
294 // Update fernet tokens before doing request on keystone server
295 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
296
297 // Check glance service
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100298 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100299
300 // Install and check nova service
301 //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1)
302 salt.enforceState(saltMaster, 'ctl01*', 'nova', true)
303 salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100304 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100305
306 // Install and check cinder service
307 //runSaltProcessStep(saltMaster, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
308 salt.enforceState(saltMaster, 'ctl01*', 'cinder', true)
309 salt.enforceState(saltMaster, 'I@cinder:controller', 'cinder', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100310 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100311
312 // Install neutron service
313 //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1)
Tomáš Kukrál575e38a2017-03-02 17:12:45 +0100314 if (INSTALL.toLowerCase().contains('kvm')) {
315 salt.enforceState(saltMaster, 'ntw01*', 'neutron', true)
316 } else {
317 salt.enforceState(saltMaster, 'ctl01*', 'neutron', true)
318 }
319
Tomáš Kukrála18de112017-03-02 13:57:47 +0100320 salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100321 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100322
323 // Install heat service
324 //runSaltProcessStep(saltMaster, 'I@heat:server', 'state.sls', ['heat'], 1)
325 salt.enforceState(saltMaster, 'ctl01*', 'heat', true)
326 salt.enforceState(saltMaster, 'I@heat:server', 'heat', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100327 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100328
329 // Install horizon dashboard
330 salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true)
331 salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true)
332
333 }
334
335 stage('Install OpenStack network') {
336 //orchestrate.installOpenstackMkNetwork(saltMaster, physical)
337
338 // Install opencontrail database services
339 //runSaltProcessStep(saltMaster, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
340 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail.database', true)
341 salt.enforceState(saltMaster, 'I@opencontrail:database', 'opencontrail.database', true)
342
343 // Install opencontrail control services
344 //runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
345 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail', true)
346 salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail', true)
Tomáš Kukrál3b8ad5e2017-03-02 23:03:27 +0100347 salt.enforceState(saltMaster, 'I@opencontrail:collector', 'opencontrail', true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100348
349 // Provision opencontrail control services
350 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrál575e38a2017-03-02 17:12:45 +0100351 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)
352 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)
353 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)
354 } else {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100355 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)
356 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)
357 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 +0100358 }
359
360 // Test opencontrail
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100361 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
362 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'], null, true)
363 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100364 }
365
366 stage('Install OpenStack compute') {
367 //orchestrate.installOpenstackMkCompute(saltMaster, physical)
368 // Configure compute nodes
Tomáš Kukrálda26d902017-03-02 22:19:00 +0100369 retry(2) {
Tomáš Kukrál02cda9f2017-03-02 22:32:57 +0100370 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', [], null, true)
Tomáš Kukrálda26d902017-03-02 22:19:00 +0100371 }
Tomáš Kukrála18de112017-03-02 13:57:47 +0100372
373 // Provision opencontrail virtual routers
374 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrál834fe212017-03-02 22:50:49 +0100375 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 +0100376 } else {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100377 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 +0100378 }
379
Tomáš Kukrálc39610c2017-03-02 22:56:06 +0100380 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'system.reboot', [], null, true)
Tomáš Kukrál3b8ad5e2017-03-02 23:03:27 +0100381 sleep(10)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100382 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100383 }
384
Tomáš Kukrála18de112017-03-02 13:57:47 +0100385 //
386 // Test
387 //
388
389 if (TEST.toLowerCase().contains('k8s')) {
390 stage('Run k8s bootstrap tests') {
391 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
392 }
393
394 stage('Run k8s conformance e2e tests') {
395 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
396 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100397 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100398
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100399
Tomáš Kukrála18de112017-03-02 13:57:47 +0100400 } catch (Throwable e) {
401 currentBuild.result = 'FAILURE'
402 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100403 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100404
Tomáš Kukrála18de112017-03-02 13:57:47 +0100405 //
406 // Clean
407 //
408
409 if (HEAT_STACK_DELETE == 'true' && STACK_TYPE == 'heat') {
410 stage('Trigger cleanup job') {
Tomáš Kukrál3fee50a2017-03-03 00:46:30 +0100411 build job: 'deploy-heat-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
Tomáš Kukrála18de112017-03-02 13:57:47 +0100412 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100413 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100414 }
415 }
416}