blob: b1339ef5fe0ca5a155dadd7665898fd04ce10d36 [file] [log] [blame]
Ales Komarek24097402017-05-22 16:28:10 +02001/**
2 *
Tomáš Kukrál0d00dd22017-07-27 14:28:36 +02003 * Launch stack and work with it
Ales Komarek24097402017-05-22 16:28:10 +02004 *
5 * Expected parameters:
6 * STACK_NAME Infrastructure stack name
Tomáš Kukrál4691f682017-07-27 16:36:12 +02007 * STACK_TEMPLATE File with stack template
8 * STACK_TYPE Deploy OpenStack/AWS [heat/aws], use 'physical' if no stack should be started
Ales Komarek24097402017-05-22 16:28:10 +02009 *
10 * STACK_TEMPLATE_URL URL to git repo with stack templates
11 * STACK_TEMPLATE_CREDENTIALS Credentials to the templates repo
12 * STACK_TEMPLATE_BRANCH Stack templates repo branch
13 *
14 * STACK_DELETE Delete stack when finished (bool)
Tomáš Kukrál4691f682017-07-27 16:36:12 +020015 * STACK_REUSE Reuse existing stack (don't create one, only read outputs)
Ales Komarek24097402017-05-22 16:28:10 +020016 * STACK_INSTALL What should be installed (k8s, openstack, ...)
17 * STACK_TEST Run tests (bool)
18 * STACK_CLEANUP_JOB Name of job for deleting stack
19 *
Tomáš Kukrál74f92862017-06-05 19:18:43 +020020 * STACK_COMPUTE_COUNT Number of compute nodes to launch
Vasyl Saienkoa81e9312018-03-06 01:28:35 +020021 * STACK_CLUSTER_NAME The name of cluster model to use
Jiri Broulik61b3e5d2017-12-19 15:42:30 +010022 * STATIC_MGMT_NETWORK Check if model contains static IP address definitions for all nodes
Tomáš Kukrál74f92862017-06-05 19:18:43 +020023 *
Ales Komarek24097402017-05-22 16:28:10 +020024 * AWS_STACK_REGION CloudFormation AWS region
25 * AWS_API_CREDENTIALS AWS Access key ID with AWS secret access key
Tomáš Kukrál7a8a4fa2017-05-25 14:54:24 +020026 * AWS_SSH_KEY AWS key pair name (used for SSH access)
Ales Komarek24097402017-05-22 16:28:10 +020027 *
28 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
29 * HEAT_STACK_ZONE Heat stack availability zone
30 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
31 * OPENSTACK_API_URL OpenStack API address
32 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
33 * OPENSTACK_API_PROJECT OpenStack project to connect to
34 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
35 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
Oleh Hryhorov9630a762017-10-24 14:33:25 +030036 * SLAVE_NODE Lable or node name where the job will be run
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020037
Ales Komarek24097402017-05-22 16:28:10 +020038 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
Tomáš Kukrál4691f682017-07-27 16:36:12 +020039 * required for STACK_TYPE=physical
Ales Komarek24097402017-05-22 16:28:10 +020040 * SALT_MASTER_URL URL of Salt master
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020041
Oleg Iurchenko9a8c3d72017-12-21 14:55:38 +020042 * BOOTSTRAP_EXTRA_REPO_PARAMS optional parameter to define a list of extra repos with parameters
43 * which have to be added during bootstrap.
44 * Format: repo 1, repo priority 1, repo pin 1; repo 2, repo priority 2, repo pin 2;
45
Oleh Hryhorov825b5be2018-06-13 13:01:53 +030046 * SALT_VERSION Version of Salt which is going to be installed i.e. 'stable 2016.3' or 'stable 2017.7' etc.
47 *
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +030048 * EXTRA_TARGET The value will be added to target nodes
Denis Egorenkoca6aeca2019-08-19 19:41:27 +040049 * BATCH_SIZE Use batching for states, which may be targeted for huge amount of nodes. Format:
50 - 10 - number of nodes
51 - 10% - percentage of all targeted nodes
Ivan Berezovskiycf960672020-01-27 14:25:31 +040052 * DIST_UPGRADE_NODES Whether to run "apt-get dist-upgrade" on all nodes in cluster before deployment
Denis V. Meltsaykin396632d2020-05-18 15:39:36 +020053 * UPGRADE_SALTSTACK Whether to install recent versions of saltstack packages
Denis Egorenkoca6aeca2019-08-19 19:41:27 +040054
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +030055 *
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020056 * Test settings:
57 * TEST_K8S_API_SERVER Kubernetes API address
58 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Ales Komarek24097402017-05-22 16:28:10 +020059 *
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020060 * TEST_DOCKER_INSTALL Install docker on the target if true
61 * TEST_TEMPEST_IMAGE Tempest image link
62 * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only
63 * TEST_TEMPEST_TARGET Salt target for tempest node
ibumarskov637a2152018-01-16 10:39:57 +040064 * TESTRAIL_REPORT Whether upload results to testrail or not
65 * TESTRAIL_REPORTER_IMAGE Docker image for testrail reporter
66 * TESTRAIL_QA_CREDENTIALS Credentials for upload to testrail
67 * TESTRAIL_MILESTONE Product version for tests
68 * TESTRAIL_PLAN Testrail test plan
69 * TESTRAIL_GROUP Testrail test group
70 * TESTRAIL_SUITE Testrail test suite
Ales Komarek24097402017-05-22 16:28:10 +020071 *
Tomáš Kukrál5c2ec132017-07-26 09:57:27 +020072 * optional parameters for overwriting soft params
73 * SALT_OVERRIDES YAML with overrides for Salt deployment
Ales Komarek24097402017-05-22 16:28:10 +020074 *
75 */
Tomáš Kukrál3a17dd62017-07-27 18:24:16 +020076
Ales Komarek24097402017-05-22 16:28:10 +020077common = new com.mirantis.mk.Common()
78git = new com.mirantis.mk.Git()
79openstack = new com.mirantis.mk.Openstack()
Tomáš Kukrál7a8a4fa2017-05-25 14:54:24 +020080aws = new com.mirantis.mk.Aws()
Ales Komarek24097402017-05-22 16:28:10 +020081orchestrate = new com.mirantis.mk.Orchestrate()
Mykyta Karpine016d7e2017-10-09 13:35:20 +030082python = new com.mirantis.mk.Python()
Ales Komarek24097402017-05-22 16:28:10 +020083salt = new com.mirantis.mk.Salt()
84test = new com.mirantis.mk.Test()
Ivan Berezovskiycf960672020-01-27 14:25:31 +040085debian = new com.mirantis.mk.Debian()
Ales Komarek24097402017-05-22 16:28:10 +020086
87_MAX_PERMITTED_STACKS = 2
88overwriteFile = "/srv/salt/reclass/classes/cluster/override.yml"
89
Tomáš Kukrála1d86b82017-07-10 17:24:01 +020090// Define global variables
Tomáš Kukrála1d86b82017-07-10 17:24:01 +020091def venv
chnyda597fb032017-10-06 13:42:48 +020092def venvPepper
Tomáš Kukrál8e50d8e2017-09-01 17:40:53 +020093def outputs = [:]
Tomáš Kukrálbc4be252017-06-06 11:28:40 +020094
chnydae14058a2017-08-29 15:07:48 +020095def ipRegex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
96
Tomáš Kukrálb19bdda2017-06-13 17:09:43 +020097if (STACK_TYPE == 'aws') {
Tomáš Kukrála1d86b82017-07-10 17:24:01 +020098 def aws_env_vars
Tomáš Kukrál8427ff52017-08-30 15:46:52 +020099} else if (STACK_TYPE == 'heat') {
100 def envParams
101 def openstackCloud
Tomáš Kukrálb19bdda2017-06-13 17:09:43 +0200102}
103
Oleh Hryhorov9630a762017-10-24 14:33:25 +0300104def slave_node = 'python'
105
Oleh Hryhorov54460512017-10-26 18:45:36 +0300106if (common.validInputParam('SLAVE_NODE')) {
Oleh Hryhorov9630a762017-10-24 14:33:25 +0300107 slave_node = SLAVE_NODE
108}
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300109
110def extra_tgt = ''
111if (common.validInputParam('EXTRA_TARGET')) {
112 extra_tgt = "${EXTRA_TARGET}"
113}
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400114def batch_size = ''
115if (common.validInputParam('BATCH_SIZE')) {
116 batch_size = "${BATCH_SIZE}"
117}
Ivan Berezovskiycf960672020-01-27 14:25:31 +0400118def upgrade_nodes = false
119if (common.validInputParam('DIST_UPGRADE_NODES')) {
120 upgrade_nodes = "${DIST_UPGRADE_NODES}".toBoolean()
121}
Denis V. Meltsaykin396632d2020-05-18 15:39:36 +0200122def upgrade_salt = false
123if (common.validInputParam('UPGRADE_SALTSTACK')){
124 upgrade_salt = "${UPGRADE_SALTSTACK}".toBoolean()
125}
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300126
Jakub Josefa63f9862018-01-11 17:58:38 +0100127timeout(time: 12, unit: 'HOURS') {
128 node(slave_node) {
129 try {
130 // Set build-specific variables
Jakub Josef88aaf832018-01-18 16:18:28 +0100131 def workspace = common.getWorkspace()
132 venv = "${workspace}/venv"
133 venvPepper = "${workspace}/venvPepper"
Jakub Josef052e77a2018-03-05 15:19:03 +0100134 if(common.validInputParam("STACK_DELETE") && STACK_DELETE.toBoolean()){
135 common.warningMsg("You running stack with STACK_DELETE option enabled, deployed stack will be removed at the end!")
136 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100137 //
138 // Prepare machines
139 //
140 stage ('Create infrastructure') {
Tomáš Kukrála1d86b82017-07-10 17:24:01 +0200141
Jakub Josefa63f9862018-01-11 17:58:38 +0100142 outputs.put('stack_type', STACK_TYPE)
Ales Komarek24097402017-05-22 16:28:10 +0200143
Jakub Josefa63f9862018-01-11 17:58:38 +0100144 if (STACK_TYPE == 'heat') {
145 // value defaults
146 envParams = [
147 'cluster_zone': HEAT_STACK_ZONE,
148 'cluster_public_net': HEAT_STACK_PUBLIC_NET
149 ]
Tomáš Kukrál8e50d8e2017-09-01 17:40:53 +0200150
Jakub Josefa63f9862018-01-11 17:58:38 +0100151 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
152 error("If you want to reuse existing stack you need to provide it's name")
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400153 }
Tomáš Kukrál550364e2017-08-23 11:42:45 +0200154
Jakub Josefa63f9862018-01-11 17:58:38 +0100155 if (STACK_REUSE.toBoolean() == false) {
156 // Don't allow to set custom heat stack name
157 wrap([$class: 'BuildUser']) {
158 if (env.BUILD_USER_ID) {
159 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
160 } else {
161 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
162 }
163 currentBuild.description = STACK_NAME
Ales Komarek24097402017-05-22 16:28:10 +0200164 }
Inessa Vasilevskaya7fd23f22018-10-09 10:58:46 +0200165 } else {
166 // In case name was copied with unicode zero-width space chars -
167 // remove them
168 STACK_NAME = STACK_NAME.trim().replaceAll("\\p{C}", "")
Ales Komarek24097402017-05-22 16:28:10 +0200169 }
170
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400171 // no underscore in STACK_NAME
172 STACK_NAME = STACK_NAME.replaceAll('_', '-')
Jakub Josefa63f9862018-01-11 17:58:38 +0100173 outputs.put('stack_name', STACK_NAME)
Ales Komarek24097402017-05-22 16:28:10 +0200174
Jakub Josefa63f9862018-01-11 17:58:38 +0100175 // set description
176 currentBuild.description = "${STACK_NAME}"
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400177
Ales Komarek24097402017-05-22 16:28:10 +0200178 // get templates
179 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
180
Jakub Josefa63f9862018-01-11 17:58:38 +0100181 // create openstack env
182 openstack.setupOpenstackVirtualenv(venv, OPENSTACK_API_CLIENT)
Jakub Josef88aaf832018-01-18 16:18:28 +0100183 openstackCloud = openstack.createOpenstackEnv(venv,
Jakub Josefa63f9862018-01-11 17:58:38 +0100184 OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
185 OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
186 OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
187 OPENSTACK_API_VERSION)
188 openstack.getKeystoneToken(openstackCloud, venv)
Ales Komarek24097402017-05-22 16:28:10 +0200189
Jakub Josefa63f9862018-01-11 17:58:38 +0100190 //
191 // Verify possibility of create stack for given user and stack type
192 //
193 wrap([$class: 'BuildUser']) {
194 if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) {
195 def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}".replaceAll('_', '-'), venv)
196 if (existingStacks.size() >= _MAX_PERMITTED_STACKS) {
197 STACK_DELETE = "false"
198 throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
199 }
200 }
Tomáš Kukrál8e50d8e2017-09-01 17:40:53 +0200201 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100202 // launch stack
203 if (STACK_REUSE.toBoolean() == false) {
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400204
Jakub Josefa63f9862018-01-11 17:58:38 +0100205 // set reclass repo in heat env
206 try {
207 envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH)
208 envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS)
209 } catch (MissingPropertyException e) {
210 common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.")
Tomáš Kukrálf83409d2017-11-08 20:56:57 +0100211 }
212
Jakub Josefa63f9862018-01-11 17:58:38 +0100213 // put formulas revision - stable, testing or nightly
214 if (common.validInputParam('FORMULA_PKG_REVISION')) {
215 common.infoMsg("Setting formulas revision to ${FORMULA_PKG_REVISION}")
216 envParams.put('cfg_formula_pkg_revision', FORMULA_PKG_REVISION)
217 }
218
219 // put extra repo definitions
220 if (common.validInputParam('BOOTSTRAP_EXTRA_REPO_PARAMS')) {
221 common.infoMsg("Setting additional repo during bootstrap to ${BOOTSTRAP_EXTRA_REPO_PARAMS}")
222 envParams.put('cfg_bootstrap_extra_repo_params', BOOTSTRAP_EXTRA_REPO_PARAMS)
223 }
224
azvyagintsevb8ddb492018-09-12 14:59:45 +0300225 // put extra salt-formulas # FIXME: looks like some outdated logic. See #PROD-23127
Jakub Josefa63f9862018-01-11 17:58:38 +0100226 if (common.validInputParam('EXTRA_FORMULAS')) {
227 common.infoMsg("Setting extra salt-formulas to ${EXTRA_FORMULAS}")
228 envParams.put('cfg_extra_formulas', EXTRA_FORMULAS)
229 }
230
Vasyl Saienkoa81e9312018-03-06 01:28:35 +0200231 // add cluster name if specified
232 if (common.validInputParam('STACK_CLUSTER_NAME')) {
233 common.infoMsg("Setting cluster_name to ${STACK_CLUSTER_NAME}")
234 envParams.put('cluster_name', STACK_CLUSTER_NAME)
235 }
236
Vasyl Saienko51139fd2018-04-20 12:01:50 +0300237 if (common.validInputParam('STACK_COMPUTE_COUNT')) {
238 if (STACK_COMPUTE_COUNT.toInteger() > 0){
239 common.infoMsg("Setting cluster_node_count to ${STACK_COMPUTE_COUNT}")
240 envParams.put('cluster_node_count', STACK_COMPUTE_COUNT)
241 }
242 }
243
Oleh Hryhorov825b5be2018-06-13 13:01:53 +0300244
245 if (common.validInputParam('SALT_VERSION')) {
246 common.infoMsg("Setting salt version to ${SALT_VERSION}")
247 envParams.put('cfg_saltversion', SALT_VERSION)
248 }
249
Mykyta Karpin35f71332018-07-27 11:54:51 +0300250 // If stack wasn't removed by the same user which has created it,
251 // nova key pair won't be removed, so need to make sure that no
252 // key pair with the same name exists before creating the stack.
253 if (openstack.getKeyPair(openstackCloud, STACK_NAME, venv)){
254 try {
255 openstack.deleteKeyPair(openstackCloud, STACK_NAME, venv)
256 } catch (Exception e) {
257 common.errorMsg("Key pair failed to remove with error ${e.message}")
258 }
259 }
260
Jakub Josefa63f9862018-01-11 17:58:38 +0100261 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv)
262 }
263
264 // get SALT_MASTER_URL
265 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', venv)
266 // check that saltMasterHost is valid
267 if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
268 common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
269 throw new Exception("saltMasterHost is not a valid ip")
270 }
271
272 currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
273
274 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
275
276 } else if (STACK_TYPE == 'aws') {
277
278 // setup environment
279 aws.setupVirtualEnv(venv)
280
281 // set aws_env_vars
282 aws_env_vars = aws.getEnvVars(AWS_API_CREDENTIALS, AWS_STACK_REGION)
283
284 if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
285 error("If you want to reuse existing stack you need to provide it's name")
286 }
287
288 if (STACK_REUSE.toBoolean() == false) {
289 // Don't allow to set custom stack name
290 wrap([$class: 'BuildUser']) {
291 if (env.BUILD_USER_ID) {
292 STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
293 } else {
294 STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
295 }
296 }
297
298 // no underscore in STACK_NAME
299 STACK_NAME = STACK_NAME.replaceAll('_', '-')
300 }
301
302 // set description
303 currentBuild.description = STACK_NAME
304 outputs.put('stack_name', STACK_NAME)
305
306 if (STACK_REUSE.toBoolean() == false) {
307 // get templates
308 git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
309
310 // start stack
311 def stack_params = [
312 "ParameterKey=KeyName,ParameterValue=" + AWS_SSH_KEY,
313 "ParameterKey=CmpNodeCount,ParameterValue=" + STACK_COMPUTE_COUNT
314 ]
315 def template_file = 'cfn/' + STACK_TEMPLATE + '.yml'
316 aws.createStack(venv, aws_env_vars, template_file, STACK_NAME, stack_params)
317 }
318
319 // wait for stack to be ready
320 aws.waitForStatus(venv, aws_env_vars, STACK_NAME, 'CREATE_COMPLETE')
321
322 // get outputs
323 saltMasterHost = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'SaltMasterIP')
324
325 // check that saltMasterHost is valid
326 if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
327 common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
328 throw new Exception("saltMasterHost is not a valid ip")
329 }
330
331 currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
332 SALT_MASTER_URL = "http://${saltMasterHost}:6969"
333
334 } else if (STACK_TYPE != 'physical') {
335 throw new Exception("STACK_TYPE ${STACK_TYPE} is not supported")
336 }
337
338 outputs.put('salt_api', SALT_MASTER_URL)
339
340 // Setup virtualenv for pepper
341 python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
342 }
343
344
345 // Set up override params
346 if (common.validInputParam('SALT_OVERRIDES')) {
347 stage('Set Salt overrides') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300348 salt.setSaltOverrides(venvPepper, SALT_OVERRIDES, '/srv/salt/reclass', extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100349 }
350 }
351
352 //
353 // Install
354 //
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400355 if (!batch_size) {
Denis Egorenko7b098c32019-12-19 16:45:25 +0400356 // if no batch size provided get current worker threads and set batch size to 2/3 of it to avoid
357 // 'SaltReqTimeoutError: Message timed out' issue on Salt targets for large amount of nodes
358 // do not use toDouble/Double as it requires additional approved method
359 def workerThreads = salt.getWorkerThreads(venvPepper).toInteger()
360 batch_size = (workerThreads * 2 / 3).toString().tokenize('.')[0]
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400361 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100362
Martin Polreichacc8b192019-03-28 12:50:57 +0100363 // Check if all minions are reachable and ready
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400364 salt.checkTargetMinionsReady(['saltId': venvPepper, 'target': '*', batch: batch_size])
Martin Polreichacc8b192019-03-28 12:50:57 +0100365
Jakub Josefa63f9862018-01-11 17:58:38 +0100366 if (common.checkContains('STACK_INSTALL', 'core')) {
367 stage('Install core infrastructure') {
368 def staticMgmtNetwork = false
369 if (common.validInputParam('STATIC_MGMT_NETWORK')) {
370 staticMgmtNetwork = STATIC_MGMT_NETWORK.toBoolean()
371 }
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400372 orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork, extra_tgt, batch_size)
Jakub Josefa63f9862018-01-11 17:58:38 +0100373
Denis V. Meltsaykin396632d2020-05-18 15:39:36 +0200374 if (upgrade_salt) {
375 debian.upgradeSaltPackages(venvPepper, 'I@salt:master')
376 debian.upgradeSaltPackages(venvPepper, 'I@salt:minion and not I@salt:master')
377 }
378
Jakub Josefa63f9862018-01-11 17:58:38 +0100379 if (common.checkContains('STACK_INSTALL', 'kvm')) {
Ivan Berezovskiycf960672020-01-27 14:25:31 +0400380 if (upgrade_nodes) {
381 debian.osUpgradeNode(venvPepper, 'I@salt:control', 'dist-upgrade', 30, 20, batch_size)
382 salt.checkTargetMinionsReady(['saltId': venvPepper, 'target': 'I@salt:control', wait: 60, timeout: 10])
383 }
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300384 orchestrate.installInfraKvm(venvPepper, extra_tgt)
Ivan Berezovskiycf960672020-01-27 14:25:31 +0400385 orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork, extra_tgt, batch_size)
Jakub Josefa63f9862018-01-11 17:58:38 +0100386 }
387
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300388 orchestrate.validateFoundationInfra(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100389 }
Ivan Berezovskiycf960672020-01-27 14:25:31 +0400390 if (upgrade_nodes) {
391 debian.osUpgradeNode(venvPepper, 'not ( I@salt:master or I@salt:control )', 'dist-upgrade', false, 30, 10, batch_size)
392 salt.checkTargetMinionsReady(['saltId': venvPepper, 'target': 'not ( I@salt:master or I@salt:control )', wait: 60, timeout: 10])
393 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100394 }
395
Oleksii Grudevd3d5fad2018-06-29 16:25:35 +0300396 stage('Install infra') {
397 if (common.checkContains('STACK_INSTALL', 'core') ||
398 common.checkContains('STACK_INSTALL', 'openstack') ||
Denis Egorenko9b7f0972019-11-07 20:42:43 +0400399 common.checkContains('STACK_INSTALL', 'oss') ||
400 common.checkContains('STACK_INSTALL', 'cicd')) {
Oleksii Grudevd3d5fad2018-06-29 16:25:35 +0300401 orchestrate.installInfra(venvPepper, extra_tgt)
402 }
403 }
404
Vasyl Saienko4c78fe12018-08-06 10:17:28 +0300405 stage('Install Orchestrated Apps'){
406 orchestrate.OrchestrateApplications(venvPepper, "I@salt:master ${extra_tgt}", "orchestration.deploy.applications")
407 }
408
Jakub Josefa63f9862018-01-11 17:58:38 +0100409 // install k8s
410 if (common.checkContains('STACK_INSTALL', 'k8s')) {
411
412 stage('Install Kubernetes infra') {
413 if (STACK_TYPE == 'aws') {
414 // configure kubernetes_control_address - save loadbalancer
415 def awsOutputs = aws.getOutputs(venv, aws_env_vars, STACK_NAME)
416 common.prettyPrint(awsOutputs)
417 if (awsOutputs.containsKey('ControlLoadBalancer')) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300418 salt.runSaltProcessStep(venvPepper, "I@salt:master ${extra_tgt}", 'reclass.cluster_meta_set', ['kubernetes_control_address', awsOutputs['ControlLoadBalancer']], null, true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100419 outputs.put('kubernetes_apiserver', 'https://' + awsOutputs['ControlLoadBalancer'])
420 }
421 }
422
423 // ensure certificates are generated properly
Andrey Shestakovf23ed002018-08-21 12:09:51 +0300424 salt.runSaltProcessStep(venvPepper, "I@kubernetes:* ${extra_tgt}", 'saltutil.refresh_pillar', [], null, true)
425 salt.enforceState(venvPepper, "I@kubernetes:* ${extra_tgt}", ['salt.minion.cert'], true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100426 }
427
428 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Svimbaa554ea02018-06-06 18:45:23 +0200429 stage('Install Contrail control') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300430 orchestrate.installContrailNetwork(venvPepper, extra_tgt)
Tomáš Kukrál39c96cd2017-07-11 10:14:13 +0200431 }
Ales Komarek24097402017-05-22 16:28:10 +0200432 }
Tomáš Kukrálf83409d2017-11-08 20:56:57 +0100433
Jakub Josefa63f9862018-01-11 17:58:38 +0100434 stage('Install Kubernetes control') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300435 orchestrate.installKubernetesControl(venvPepper, extra_tgt)
Anton Samoylove53f9382019-01-23 20:22:26 +0400436 if (common.checkContains('STACK_INSTALL', 'contrail')) {
437 orchestrate.checkContrailApiReadiness(venvPepper, extra_tgt)
438 }
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400439
Jakub Josefa63f9862018-01-11 17:58:38 +0100440 // collect artifacts (kubeconfig)
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300441 writeFile(file: 'kubeconfig', text: salt.getFileContent(venvPepper, "I@kubernetes:master and *01* ${extra_tgt}", '/etc/kubernetes/admin-kube-config'))
Jakub Josefa63f9862018-01-11 17:58:38 +0100442 archiveArtifacts(artifacts: 'kubeconfig')
vrovachev7be1e962017-07-05 13:28:26 +0400443 }
444
Svimbaa554ea02018-06-06 18:45:23 +0200445 if (common.checkContains('STACK_INSTALL', 'contrail')) {
446 stage('Install Contrail compute') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300447 orchestrate.installContrailCompute(venvPepper, extra_tgt)
Svimbaa554ea02018-06-06 18:45:23 +0200448 }
449 }
450
Jakub Josefa63f9862018-01-11 17:58:38 +0100451 stage('Install Kubernetes computes') {
452 if (common.validInputParam('STACK_COMPUTE_COUNT')) {
453 if (STACK_COMPUTE_COUNT > 0) {
454 if (STACK_TYPE == 'aws') {
455 // get stack info
456 def scaling_group = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'ComputesScalingGroup')
457
458 //update autoscaling group
459 aws.updateAutoscalingGroup(venv, aws_env_vars, scaling_group, ["--desired-capacity " + STACK_COMPUTE_COUNT])
460
461 // wait for computes to boot up
462 aws.waitForAutoscalingInstances(venv, aws_env_vars, scaling_group)
463 sleep(60)
464
465 } else if (STACK_TYPE == 'heat') {
466 envParams.put('cluster_node_count', STACK_COMPUTE_COUNT)
467
468 openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv, "update")
469 sleep(60)
470 }
471
472 }
473 }
474
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300475 orchestrate.installKubernetesCompute(venvPepper, extra_tgt)
Svimbaa979f8f2018-09-26 11:24:49 +0200476 // Setup kubernetes addons for opencontrail. More info in the definition of the func.
477 orchestrate.setupKubeAddonForContrail(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100478 }
Vasyl Saienkocdf8b292019-03-05 10:56:29 +0200479 orchestrate.installKubernetesClient(venvPepper, extra_tgt)
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400480 }
Ales Komarek24097402017-05-22 16:28:10 +0200481
Mykyta Karpin5b7c2602018-09-11 17:47:20 +0300482 // install ceph
483 if (common.checkContains('STACK_INSTALL', 'ceph')) {
484 stage('Install Ceph MONs') {
485 orchestrate.installCephMon(venvPepper, "I@ceph:mon ${extra_tgt}", extra_tgt)
486 }
487
488 stage('Install Ceph OSDs') {
489 orchestrate.installCephOsd(venvPepper, "I@ceph:osd ${extra_tgt}", true, extra_tgt)
490 }
491
492 stage('Install Ceph clients') {
493 orchestrate.installCephClient(venvPepper, extra_tgt)
494 }
495 }
496
Vasyl Saienkoc562fc42018-12-15 22:19:28 +0200497 // install docker swarm
498 orchestrate.installDockerSwarm(venvPepper, extra_tgt)
499
Jakub Josefa63f9862018-01-11 17:58:38 +0100500 // install openstack
501 if (common.checkContains('STACK_INSTALL', 'openstack')) {
Oleksii Grudevd3d5fad2018-06-29 16:25:35 +0300502 // install control, tests, ...
Jakub Josefa63f9862018-01-11 17:58:38 +0100503 stage('Install OpenStack control') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300504 orchestrate.installOpenstackControl(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100505 }
506
Oleg Iurchenko86f1a842018-02-13 22:18:28 +0200507 // Workaround for PROD-17765 issue to prevent crashes of keystone.role_present state.
508 // More details: https://mirantis.jira.com/browse/PROD-17765
Ivan Berezovskiyddd0cbb2019-08-01 15:23:14 +0400509 salt.restartSaltMinion(venvPepper, "I@keystone:client ${extra_tgt}")
Denis V. Meltsaykinfd7586b2020-06-02 11:23:18 +0200510 salt.minionsReachable(venvPepper, 'I@salt:master', "I@keystone:client ${extra_tgt}", null, 10, 6)
Oleg Iurchenko86f1a842018-02-13 22:18:28 +0200511
Jakub Josefa63f9862018-01-11 17:58:38 +0100512 stage('Install OpenStack network') {
513
514 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300515 orchestrate.installContrailNetwork(venvPepper, extra_tgt)
Anton Samoylove53f9382019-01-23 20:22:26 +0400516 orchestrate.checkContrailApiReadiness(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100517 } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300518 orchestrate.installOpenstackNetwork(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100519 }
520
Petr Jedinýefd668f2018-05-24 14:44:08 +0200521 // Wait for network to come up, 150s should be enough
522 common.retry(10, 15) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300523 salt.cmdRun(venvPepper, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; openstack network list')
Petr Jedinýefd668f2018-05-24 14:44:08 +0200524 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100525 }
526
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300527 if (salt.testTarget(venvPepper, "I@ironic:conductor ${extra_tgt}")){
Jakub Josefa63f9862018-01-11 17:58:38 +0100528 stage('Install OpenStack Ironic conductor') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300529 orchestrate.installIronicConductor(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100530 }
531 }
532
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300533 if (salt.testTarget(venvPepper, "I@manila:share ${extra_tgt}")){
Vasyl Saienkob800a0f2018-02-21 18:38:53 +0200534 stage('Install OpenStack Manila data and share') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300535 orchestrate.installManilaShare(venvPepper, extra_tgt)
Vasyl Saienkob800a0f2018-02-21 18:38:53 +0200536 }
537 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100538
539 stage('Install OpenStack compute') {
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400540 orchestrate.installOpenstackCompute(venvPepper, extra_tgt, batch_size)
Jakub Josefa63f9862018-01-11 17:58:38 +0100541
542 if (common.checkContains('STACK_INSTALL', 'contrail')) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300543 orchestrate.installContrailCompute(venvPepper, extra_tgt)
Inessa Vasilevskaya30cb7312018-10-08 12:13:03 +0200544 orchestrate.installBackup(venvPepper, 'contrail', extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100545 }
546 }
547
548 }
549
Mykyta Karpin5b7c2602018-09-11 17:47:20 +0300550 // connect ceph
Jakub Josefa63f9862018-01-11 17:58:38 +0100551 if (common.checkContains('STACK_INSTALL', 'ceph')) {
Jakub Josefa63f9862018-01-11 17:58:38 +0100552
553 stage('Connect Ceph') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300554 orchestrate.connectCeph(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100555 }
556 }
557
558 if (common.checkContains('STACK_INSTALL', 'oss')) {
559 stage('Install Oss infra') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300560 orchestrate.installOssInfra(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100561 }
562 }
563
564 if (common.checkContains('STACK_INSTALL', 'cicd')) {
565 stage('Install Cicd') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300566 orchestrate.installCicd(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100567 }
568 }
569
570 if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
571 stage('Install StackLight v1') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300572 orchestrate.installStacklightv1Control(venvPepper, extra_tgt)
573 orchestrate.installStacklightv1Client(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100574 }
575 }
576
577 if (common.checkContains('STACK_INSTALL', 'stacklight')) {
578 stage('Install StackLight') {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300579 orchestrate.installStacklight(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100580 }
581 }
582
583 if (common.checkContains('STACK_INSTALL', 'oss')) {
584 stage('Install OSS') {
585 if (!common.checkContains('STACK_INSTALL', 'stacklight')) {
586 // In case if StackLightv2 enabled containers already started
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300587 salt.enforceState(venvPepper, "I@docker:swarm:role:master and I@devops_portal:config ${extra_tgt}", 'docker.client', true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100588 }
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300589 orchestrate.installOss(venvPepper, extra_tgt)
Jakub Josefa63f9862018-01-11 17:58:38 +0100590 }
591 }
592
593 //
594 // Test
595 //
596 def artifacts_dir = '_artifacts/'
597
598 if (common.checkContains('STACK_TEST', 'k8s')) {
599 stage('Run k8s conformance e2e tests') {
600 def image = TEST_K8S_CONFORMANCE_IMAGE
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400601 def autodetect = AUTODETECT
602 def ctl_target = 'I@kubernetes:master'
603 firstTarget = salt.getFirstMinion(venvPepper, ctl_target)
604 def containerd_enabled = salt.getPillar(
605 venvPepper, firstTarget, "kubernetes:common:containerd:enabled"
606 )["return"][0].values()[0].toBoolean()
607 if (containerd_enabled) {
608 def config = ['master': venvPepper,
609 'target': firstTarget,
610 'junitResults': true,
611 'autodetect': autodetect,
612 'image': image]
613 test.executeConformance(config)
614 } else {
615 def output_file = image.replaceAll('/', '-') + '.output'
Denis Egorenko14fa6e12019-08-23 14:29:34 +0400616 def target = "I@keystone:server:role:primary ${extra_tgt}"
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400617 def conformance_output_file = 'conformance_test.tar'
Jakub Josefa63f9862018-01-11 17:58:38 +0100618
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400619 // run image
620 test.runConformanceTests(venvPepper, target, TEST_K8S_API_SERVER, image)
Jakub Josefa63f9862018-01-11 17:58:38 +0100621
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400622 // collect output
623 sh "mkdir -p ${artifacts_dir}"
624 file_content = salt.getFileContent(venvPepper, target, '/tmp/' + output_file)
625 writeFile file: "${artifacts_dir}${output_file}", text: file_content
626 sh "cat ${artifacts_dir}${output_file}"
Jakub Josefa63f9862018-01-11 17:58:38 +0100627
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400628 // collect artifacts
629 archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
vrovachevff3e72d2018-01-25 16:14:43 +0400630
Victor Ryzhenkin723bd062018-12-11 17:09:06 +0400631 // Copy test results
632 test.CopyConformanceResults(venvPepper, target, artifacts_dir, conformance_output_file)
633 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100634 }
635 }
636
637 if (common.checkContains('STACK_TEST', 'openstack')) {
638 if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
639 test.install_docker(venvPepper, TEST_TEMPEST_TARGET)
640 }
641 stage('Run OpenStack tests') {
642 test.runTempestTests(venvPepper, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
643 }
644
645 stage('Copy Tempest results to config node') {
646 test.copyTempestResults(venvPepper, TEST_TEMPEST_TARGET)
647 }
648
649 stage('Archive rally artifacts') {
650 test.archiveRallyArtifacts(venvPepper, TEST_TEMPEST_TARGET)
Tomáš Kukrál74f92862017-06-05 19:18:43 +0200651 }
ibumarskov637a2152018-01-16 10:39:57 +0400652
653 if (common.validInputParam('TESTRAIL_REPORT') && TESTRAIL_REPORT.toBoolean()) {
654 stage('Upload test results to TestRail') {
655 def date = sh(script: 'date +%Y-%m-%d', returnStdout: true).trim()
656 def plan = TESTRAIL_PLAN ?: "[${TESTRAIL_MILESTONE}]System-Devcloud-${date}"
657 def group = TESTRAIL_GROUP ?: STACK_TEMPLATE
658
659 salt.cmdRun(venvPepper, TEST_TEMPEST_TARGET, "cd /root/rally_reports && cp \$(ls -t *xml | head -n1) report.xml")
660 test.uploadResultsTestrail("/root/rally_reports/report.xml",
661 TESTRAIL_REPORTER_IMAGE, group, TESTRAIL_QA_CREDENTIALS,
662 plan, TESTRAIL_MILESTONE, TESTRAIL_SUITE)
663 }
664 }
Ales Komarek24097402017-05-22 16:28:10 +0200665 }
666
Ales Komarek24097402017-05-22 16:28:10 +0200667
Jakub Josefa63f9862018-01-11 17:58:38 +0100668 if (common.checkContains('STACK_TEST', 'ceph')) {
669 stage('Run infra tests') {
670 sleep(120)
671 def cmd = "apt-get install -y python-pip && pip install -r /usr/share/salt-formulas/env/ceph/files/testinfra/requirements.txt && python -m pytest --junitxml=/root/report.xml /usr/share/salt-formulas/env/ceph/files/testinfra/"
672 salt.cmdRun(venvPepper, 'I@salt:master', cmd, false)
673 writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper, 'I@salt:master', '/root/report.xml'))
674 junit(keepLongStdio: true, testResults: 'report.xml')
Martin Polreich46971102017-07-11 12:56:40 +0200675 }
676 }
677
Jakub Josefa63f9862018-01-11 17:58:38 +0100678 if (common.checkContains('STACK_TEST', 'opencontrail')) {
679 stage('Run opencontrail tests') {
680 def opencontrail_tests_dir = "/opt/opencontrail_test/fuel-plugin-contrail/plugin_test/vapor/"
681 def report_dir = "/opt/opencontrail-test-report/"
682 def cmd = ". ${opencontrail_tests_dir}exports.sh && " +
683 "cd ${opencontrail_tests_dir} && " +
684 "py.test --junit-xml=${report_dir}report.xml" +
685 " --html=${report_dir}report.html -v vapor/tests/ -k 'not destructive' "
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400686
Denis Egorenko14fa6e12019-08-23 14:29:34 +0400687 salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'saltutil.refresh_pillar', [], null, true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100688 salt.enforceState(venvPepper, 'I@opencontrail:test' , 'opencontrail.test' , true)
Jiri Broulikd01c42f2018-01-02 11:37:10 +0100689
Jakub Josefa63f9862018-01-11 17:58:38 +0100690 salt.cmdRun(venvPepper, 'I@opencontrail:test', cmd, false)
691
692 writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper,
693 'I@opencontrail:test', "${report_dir}report.xml"))
694 junit(keepLongStdio: true, testResults: 'report.xml')
695 }
Jiri Broulikd01c42f2018-01-02 11:37:10 +0100696 }
697
698
Jakub Josefa63f9862018-01-11 17:58:38 +0100699 stage('Finalize') {
700 if (common.checkContains('STACK_INSTALL', 'finalize')) {
Oleh Hryhorov2a63aa62018-06-22 17:26:41 +0300701 def gluster_compound = "I@glusterfs:server ${extra_tgt}"
702 def salt_ca_compound = "I@salt:minion:ca:salt_master_ca ${extra_tgt}"
Dzmitry Stremkouskifa4c1632018-03-21 17:55:39 +0100703 // Enforce highstate asynchronous only on the nodes which are not glusterfs servers
Denis Egorenkoca6aeca2019-08-19 19:41:27 +0400704 salt.enforceHighstate(venvPepper, '* and not ' + gluster_compound + ' and not ' + salt_ca_compound, batch_size)
Dzmitry Stremkouskifa4c1632018-03-21 17:55:39 +0100705 // Iterate over nonempty set of gluster servers and apply highstates one by one
706 // TODO: switch to batch once salt 2017.7+ would be used
Dzmitry Stremkouski47a45122018-04-25 17:05:56 +0200707 def saltcaMinions = salt.getMinionsSorted(venvPepper, salt_ca_compound)
708 if ( !saltcaMinions.isEmpty() ) {
709 for ( target in saltcaMinions ) {
710 salt.enforceHighstate(venvPepper, target)
711 }
712 }
Dzmitry Stremkouskifa4c1632018-03-21 17:55:39 +0100713 def glusterMinions = salt.getMinionsSorted(venvPepper, gluster_compound)
714 if ( !glusterMinions.isEmpty() ) {
715 for ( target in glusterMinions ) {
716 salt.enforceHighstate(venvPepper, target)
717 }
718 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100719 }
720
721 outputsPretty = common.prettify(outputs)
722 print(outputsPretty)
723 writeFile(file: 'outputs.json', text: outputsPretty)
724 archiveArtifacts(artifacts: 'outputs.json')
Jiri Broulikd01c42f2018-01-02 11:37:10 +0100725 }
726
Jakub Josefa63f9862018-01-11 17:58:38 +0100727 } catch (Throwable e) {
728 currentBuild.result = 'FAILURE'
729 throw e
730 } finally {
Jiri Broulikd01c42f2018-01-02 11:37:10 +0100731
Mikhail Ivanov3deb79a2017-12-06 17:44:47 +0400732
Jakub Josefa63f9862018-01-11 17:58:38 +0100733 //
734 // Clean
735 //
Ruslan Kamaldinov65144322017-08-02 15:16:55 +0400736
Jakub Josefa63f9862018-01-11 17:58:38 +0100737 if (common.validInputParam('STACK_NAME')) {
738 // send notification
739 common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
Ales Komarek24097402017-05-22 16:28:10 +0200740 }
741
Jakub Josefa63f9862018-01-11 17:58:38 +0100742 if (common.validInputParam('STACK_DELETE') && STACK_DELETE.toBoolean() == true) {
743 stage('Trigger cleanup job') {
744 common.errorMsg('Stack cleanup job triggered')
745 build(job: STACK_CLEANUP_JOB, parameters: [
746 [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
747 [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
748 [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
749 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
750 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
751 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
752 [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
753 [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
754 [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
755 [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
756 ])
757 }
758 } else {
759 if (currentBuild.result == 'FAILURE') {
760 common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.")
Vasyl Saienkoff24e582017-08-04 10:04:33 +0300761
Jakub Josefa63f9862018-01-11 17:58:38 +0100762 if (common.validInputParam('SALT_MASTER_URL')) {
763 common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
764 }
Ales Komarek24097402017-05-22 16:28:10 +0200765 }
766 }
767 }
768 }
769}