Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 1 | |
| 2 | /** |
| 3 | * Rollout changes to the node(s) configuration |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * TST_SALT_MASTER_CREDENTIALS Credentials to the Salt API (QA environment). |
| 7 | * TST_SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]. |
| 8 | * PRD_SALT_MASTER_CREDENTIALS Credentials to the Salt API (PRD environment). |
| 9 | * PRD_SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]. |
| 10 | * Model parameters: |
| 11 | * MODEL_REPO_CREDENTIALS Credentials to the Model. |
| 12 | * MODEL_REPO_URL Full model repo address. |
| 13 | * MODEL_REPO_SOURCE_BRANCH Source branch to merge from. |
| 14 | * MODEL_REPO_TARGET_BRANCH Target branch to merge fo. |
| 15 | * Change settings: |
| 16 | * TARGET_SERVERS Salt compound target to match nodes to be updated [*, G@osfamily:debian]. |
| 17 | * TARGET_STATES States to be applied, empty string means running highstate [linux, linux,openssh, salt.minion.grains]. |
| 18 | * TARGET_SUBSET_TEST Number of nodes to test config changes, empty string means all targetted nodes. |
| 19 | * TARGET_SUBSET_LIVE Number of selected noded to live apply selected config changes. |
| 20 | * TARGET_BATCH_LIVE Batch size for the complete live config changes on all nodes, empty string means apply to all targetted nodes. |
| 21 | * Test settings: |
| 22 | * TEST_SERVICE Comma separated list of services to test |
| 23 | * TEST_K8S_API_SERVER Kubernetes API address |
| 24 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 25 | * TEST_DOCKER_INSTALL Install docker on the target if true |
| 26 | * TEST_TEMPEST_IMAGE Tempest image link |
| 27 | * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only |
| 28 | * TEST_TEMPEST_TARGET Salt target for tempest node |
| 29 | * |
| 30 | **/ |
| 31 | |
| 32 | def common = new com.mirantis.mk.Common() |
| 33 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 34 | timeout(time: 12, unit: 'HOURS') { |
| 35 | node() { |
| 36 | try { |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 37 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 38 | stage('Run config change on test env') { |
| 39 | build job: "deploy-update-service-config", parameters: [ |
| 40 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: TST_SALT_MASTER_URL], |
| 41 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: TST_SALT_MASTER_CREDENTIALS], |
| 42 | [$class: 'StringParameterValue', name: 'TARGET_BATCH_LIVE', value: TARGET_BATCH_LIVE], |
| 43 | [$class: 'StringParameterValue', name: 'TARGET_SERVERS', value: TARGET_SERVERS], |
| 44 | [$class: 'StringParameterValue', name: 'TARGET_STATES', value: TARGET_STATES], |
| 45 | [$class: 'StringParameterValue', name: 'TARGET_SUBSET_LIVE', value: TARGET_SUBSET_LIVE], |
| 46 | [$class: 'StringParameterValue', name: 'TARGET_SUBSET_TEST', value: TARGET_SUBSET_TEST], |
| 47 | ] |
| 48 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 49 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 50 | stage('Test config change on test env') { |
| 51 | build job: "deploy-test-service", parameters: [ |
| 52 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: TST_SALT_MASTER_URL], |
| 53 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: TST_SALT_MASTER_CREDENTIALS], |
| 54 | [$class: 'StringParameterValue', name: 'TEST_SERVICE', value: TEST_SERVICE], |
| 55 | [$class: 'StringParameterValue', name: 'TEST_K8S_API_SERVER', value: TEST_K8S_API_SERVER], |
| 56 | [$class: 'StringParameterValue', name: 'TEST_K8S_CONFORMANCE_IMAGE', value: TEST_K8S_CONFORMANCE_IMAGE], |
| 57 | ] |
| 58 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 59 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 60 | stage('Promote config change in repo') { |
| 61 | build job: "git-merge-branches", parameters: [ |
| 62 | [$class: 'StringParameterValue', name: 'REPO_URL', value: MODEL_REPO_URL], |
| 63 | [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: MODEL_REPO_CREDENTIALS], |
| 64 | [$class: 'StringParameterValue', name: 'SOURCE_BRANCH', value: MODEL_REPO_SOURCE_BRANCH], |
| 65 | [$class: 'StringParameterValue', name: 'TARGET_BRANCH', value: MODEL_REPO_TARGET_BRANCH], |
| 66 | ] |
| 67 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 68 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 69 | stage('Run config change on production env') { |
| 70 | build job: "deploy-update-service-config", parameters: [ |
| 71 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: PRD_SALT_MASTER_URL], |
| 72 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: PRD_SALT_MASTER_CREDENTIALS], |
| 73 | [$class: 'StringParameterValue', name: 'TARGET_BATCH_LIVE', value: TARGET_BATCH_LIVE], |
| 74 | [$class: 'StringParameterValue', name: 'TARGET_SERVERS', value: TARGET_SERVERS], |
| 75 | [$class: 'StringParameterValue', name: 'TARGET_STATES', value: TARGET_STATES], |
| 76 | [$class: 'StringParameterValue', name: 'TARGET_SUBSET_LIVE', value: TARGET_SUBSET_LIVE], |
| 77 | [$class: 'StringParameterValue', name: 'TARGET_SUBSET_TEST', value: TARGET_SUBSET_TEST], |
| 78 | ] |
| 79 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 80 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 81 | stage('Test config change on prod env') { |
| 82 | def result = build job: "deploy-test-service", parameters: [ |
| 83 | [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: PRD_SALT_MASTER_URL], |
| 84 | [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: PRD_SALT_MASTER_CREDENTIALS], |
| 85 | [$class: 'StringParameterValue', name: 'TEST_SERVICE', value: TEST_SERVICE], |
| 86 | [$class: 'StringParameterValue', name: 'TEST_K8S_API_SERVER', value: TEST_K8S_API_SERVER], |
| 87 | [$class: 'StringParameterValue', name: 'TEST_K8S_CONFORMANCE_IMAGE', value: TEST_K8S_CONFORMANCE_IMAGE], |
| 88 | ] |
| 89 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 90 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 91 | } catch (Throwable e) { |
| 92 | currentBuild.result = 'FAILURE' |
| 93 | throw e |
| 94 | } |
| 95 | } |
Ales Komarek | 1ebb7a8 | 2017-08-04 14:58:51 +0200 | [diff] [blame] | 96 | } |