Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 1 | /** |
| 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ál | 55357d0 | 2017-02-28 22:56:45 +0100 | [diff] [blame] | 7 | * TEST What should be tested (k8s, openstack, ...) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 8 | * |
| 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 | * |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 36 | * TEMPEST_IMAGE_LINK Tempest image link |
| 37 | * |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 38 | */ |
| 39 | |
| 40 | git = new com.mirantis.mk.Git() |
| 41 | openstack = new com.mirantis.mk.Openstack() |
| 42 | salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | 3e4029d | 2017-03-07 09:59:40 +0100 | [diff] [blame] | 43 | common = new com.mirantis.mk.Common() |
Ondrej Smola | 8f35e48 | 2017-03-30 14:04:36 +0200 | [diff] [blame] | 44 | test = new com.mirantis.mk.Test() |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 45 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 46 | timestamps { |
| 47 | node { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 48 | try { |
| 49 | // |
| 50 | // Prepare machines |
| 51 | // |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 52 | stage ('Create infrastructure') { |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 53 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 54 | if (STACK_TYPE == 'heat') { |
| 55 | // value defaults |
| 56 | def openstackCloud |
| 57 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 58 | def openstackEnv = "${env.WORKSPACE}/venv" |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 59 | |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 60 | if (HEAT_STACK_REUSE.toBoolean() == true && HEAT_STACK_NAME == '') { |
| 61 | error("If you want to reuse existing stack you need to provide it's name") |
| 62 | } |
| 63 | |
| 64 | if (HEAT_STACK_REUSE.toBoolean() == false) { |
| 65 | // Don't allow to set custom heat stack name |
| 66 | wrap([$class: 'BuildUser']) { |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 67 | if (env.BUILD_USER_ID) { |
| 68 | HEAT_STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 69 | } else { |
| 70 | HEAT_STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
| 71 | } |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 72 | currentBuild.description = HEAT_STACK_NAME |
| 73 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 74 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 75 | |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 76 | // set description |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 77 | currentBuild.description = "${HEAT_STACK_NAME}" |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 78 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 79 | // get templates |
| 80 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
| 81 | |
| 82 | // create openstack env |
| 83 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 84 | openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
| 85 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 86 | |
| 87 | // launch stack |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 88 | if (HEAT_STACK_REUSE.toBoolean() == false) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 89 | stage('Launch new Heat stack') { |
| 90 | // create stack |
| 91 | envParams = [ |
| 92 | 'instance_zone': HEAT_STACK_ZONE, |
| 93 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 94 | ] |
| 95 | openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // get SALT_MASTER_URL |
| 100 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv) |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 101 | currentBuild.description = "${HEAT_STACK_NAME}: ${saltMasterHost}" |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 102 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 103 | if (common.checkContains('INSTALL', 'kvm')) { |
Marek Celoud | 5e442a3 | 2017-03-16 10:15:53 +0100 | [diff] [blame] | 104 | saltPort = 6969 |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 105 | } else { |
Marek Celoud | 5e442a3 | 2017-03-16 10:15:53 +0100 | [diff] [blame] | 106 | saltPort = 6969 |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 107 | } |
| 108 | |
Tomáš Kukrál | 6150929 | 2017-03-04 16:27:07 +0100 | [diff] [blame] | 109 | SALT_MASTER_URL = "http://${saltMasterHost}:${saltPort}" |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 110 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 111 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 112 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 113 | // |
| 114 | // Connect to Salt master |
| 115 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 116 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 117 | def saltMaster |
| 118 | stage('Connect to Salt API') { |
| 119 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 120 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 121 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 122 | // |
| 123 | // Install |
| 124 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 125 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 126 | if (common.checkContains('INSTALL', 'core')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 127 | stage('Install core infrastructure') { |
| 128 | // salt.master, reclass |
| 129 | // refresh_pillar |
| 130 | // sync_all |
| 131 | // linux,openssh,salt.minion.ntp |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 132 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 133 | //orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 134 | salt.enforceState(saltMaster, 'I@salt:master', ['salt.master', 'reclass'], true) |
Marek Celoud | 5329246 | 2017-03-23 23:34:18 +0100 | [diff] [blame] | 135 | salt.enforceState(saltMaster, '*', ['linux.system'], true) |
Marek Celoud | 1c1ecd1 | 2017-03-23 20:41:22 +0100 | [diff] [blame] | 136 | salt.enforceState(saltMaster, '*', ['salt.minion'], true) |
Tomáš Kukrál | 01f284a | 2017-03-02 23:14:20 +0100 | [diff] [blame] | 137 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true) |
| 138 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 139 | salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 140 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 141 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 142 | if (common.checkContains('INSTALL', 'kvm')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 143 | //orchestrate.installInfraKvm(saltMaster) |
Marek Celoud | 1c1ecd1 | 2017-03-23 20:41:22 +0100 | [diff] [blame] | 144 | //salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true) |
| 145 | //salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 146 | |
Marek Celoud | 1c1ecd1 | 2017-03-23 20:41:22 +0100 | [diff] [blame] | 147 | //salt.enforceState(saltMaster, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 148 | salt.enforceState(saltMaster, 'I@salt:control', 'libvirt', true) |
| 149 | salt.enforceState(saltMaster, 'I@salt:control', 'salt.control', true) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 150 | |
Tomáš Kukrál | 3e5c5bf | 2017-03-09 16:45:54 +0100 | [diff] [blame] | 151 | sleep(600) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 152 | |
Tomáš Kukrál | 01f284a | 2017-03-02 23:14:20 +0100 | [diff] [blame] | 153 | salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true) |
| 154 | salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 155 | |
| 156 | // workaround - install apt-transport-https |
Tomáš Kukrál | be9dfa5 | 2017-03-08 13:54:03 +0100 | [diff] [blame] | 157 | //salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'cmd.run', ['apt-get update -y && apt-get install -y apt-transport-https'], null, true) |
| 158 | //salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'pkg.install', ['apt-transport-https', 'refresh=True'], null, true) |
Marek Celoud | ce2a28b | 2017-03-13 17:11:30 +0100 | [diff] [blame] | 159 | salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'salt.minion'], true, false) |
| 160 | salt.enforceState(saltMaster, 'I@linux:system', ['openssh', 'salt.minion', 'ntp'], true, false) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | //orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 164 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['salt-key'], null, true) |
Tomáš Kukrál | 01f284a | 2017-03-02 23:14:20 +0100 | [diff] [blame] | 165 | salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'test.version', [], null, true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 166 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true) |
Tomáš Kukrál | 01f284a | 2017-03-02 23:14:20 +0100 | [diff] [blame] | 167 | salt.runSaltProcessStep(saltMaster, 'I@reclass:storage', 'reclass.inventory', [], null, true) |
| 168 | salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'state.show_top', [], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
| 172 | // install k8s |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 173 | if (common.checkContains('INSTALL', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 174 | stage('Install Kubernetes infra') { |
| 175 | //orchestrate.installOpenstackMcpInfra(saltMaster) |
| 176 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 177 | // Install glusterfs |
| 178 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service']) |
| 179 | |
| 180 | // Install keepalived |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 181 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster and *01*', 'state.sls', ['keepalived']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 182 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived']) |
| 183 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 184 | // Setup glusterfs |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 185 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server and *01*', 'state.sls', ['glusterfs.server.setup']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 186 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status']) |
| 187 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status']) |
| 188 | |
| 189 | // Install haproxy |
| 190 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'state.sls', ['haproxy']) |
| 191 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 192 | |
| 193 | // Install docker |
| 194 | salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host']) |
| 195 | salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps']) |
| 196 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 197 | // Install etcd |
| 198 | salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service']) |
Tomáš Kukrál | 67878f5 | 2017-04-20 10:33:11 +0200 | [diff] [blame] | 199 | salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 200 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 203 | stage('Install Kubernetes control') { |
| 204 | //orchestrate.installOpenstackMcpControl(saltMaster) |
Tomáš Kukrál | 06c27a9 | 2017-03-01 16:21:46 +0100 | [diff] [blame] | 205 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 206 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | 67878f5 | 2017-04-20 10:33:11 +0200 | [diff] [blame] | 207 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes.master.kube-addons']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 208 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 209 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 210 | // Setup etcd server |
Tomáš Kukrál | 67878f5 | 2017-04-20 10:33:11 +0200 | [diff] [blame] | 211 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master and *01*', 'state.sls', ['etcd.server.setup']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 212 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 213 | // Run k8s without master.setup |
| 214 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 215 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 216 | // Run k8s master setup |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 217 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master and *01*', 'state.sls', ['kubernetes.master.setup']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 218 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 219 | // Restart kubelet |
| 220 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 223 | } |
| 224 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 225 | // install openstack |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 226 | if (common.checkContains('INSTALL', 'openstack')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 227 | // install Infra and control, tests, ... |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 228 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 229 | stage('Install OpenStack infra') { |
| 230 | //orchestrate.installOpenstackMkInfra(saltMaster, physical) |
| 231 | |
Marek Celoud | 8db985f | 2017-03-14 17:41:19 +0100 | [diff] [blame] | 232 | // Install glusterfs |
| 233 | salt.enforceState(saltMaster, 'I@glusterfs:server', 'glusterfs.server.service', true) |
| 234 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 235 | // Install keepaliveds |
| 236 | //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1) |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 237 | salt.enforceState(saltMaster, 'I@keepalived:cluster and *01*', 'keepalived', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 238 | salt.enforceState(saltMaster, 'I@keepalived:cluster', 'keepalived', true) |
| 239 | |
| 240 | // Check the keepalived VIPs |
| 241 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 242 | |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 243 | salt.enforceState(saltMaster, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 244 | |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 245 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true) |
| 246 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 247 | |
| 248 | // Install rabbitmq |
Marek Celoud | 88a79a2 | 2017-03-27 15:51:41 +0200 | [diff] [blame] | 249 | withEnv(['ASK_ON_ERROR=false']){ |
| 250 | retry(2) { |
| 251 | salt.enforceState(saltMaster, 'I@rabbitmq:server', 'rabbitmq', true) |
| 252 | } |
| 253 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 254 | // Check the rabbitmq status |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame] | 255 | salt.runSaltProcessStep(saltMaster, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 256 | |
| 257 | // Install galera |
Marek Celoud | 88a79a2 | 2017-03-27 15:51:41 +0200 | [diff] [blame] | 258 | withEnv(['ASK_ON_ERROR=false']){ |
| 259 | retry(2) { |
| 260 | salt.enforceState(saltMaster, 'I@galera:master', 'galera', true) |
| 261 | } |
Marek Celoud | 7c84ef7 | 2017-03-15 17:32:32 +0100 | [diff] [blame] | 262 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 263 | salt.enforceState(saltMaster, 'I@galera:slave', 'galera', true) |
| 264 | |
| 265 | // Check galera status |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame] | 266 | salt.runSaltProcessStep(saltMaster, 'I@galera:master', 'mysql.status') |
| 267 | salt.runSaltProcessStep(saltMaster, 'I@galera:slave', 'mysql.status') |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 268 | |
Marek Celoud | cabe564 | 2017-03-15 18:16:38 +0100 | [diff] [blame] | 269 | // // Setup mysql client |
| 270 | // salt.enforceState(saltMaster, 'I@mysql:client', 'mysql.client', true) |
Tomáš Kukrál | aa8f553 | 2017-03-07 13:34:39 +0100 | [diff] [blame] | 271 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 272 | // Install haproxy |
| 273 | salt.enforceState(saltMaster, 'I@haproxy:proxy', 'haproxy', true) |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame] | 274 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 275 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 276 | |
| 277 | // Install memcached |
| 278 | salt.enforceState(saltMaster, 'I@memcached:server', 'memcached', true) |
| 279 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 280 | } |
| 281 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 282 | stage('Install OpenStack control') { |
| 283 | //orchestrate.installOpenstackMkControl(saltMaster) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 284 | |
Marek Celoud | 36d24b6 | 2017-03-21 15:07:07 +0100 | [diff] [blame] | 285 | // Install horizon dashboard |
| 286 | salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true) |
| 287 | salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true) |
| 288 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 289 | // setup keystone service |
| 290 | //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 291 | salt.enforceState(saltMaster, 'I@keystone:server and *01*', 'keystone.server', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 292 | salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true) |
| 293 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 294 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 295 | // keystone:client must be called locally |
Marek Celoud | 9bf666c | 2017-04-12 18:28:48 +0200 | [diff] [blame] | 296 | //salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 297 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'service.restart', ['apache2']) |
| 298 | salt.enforceState(saltMaster, 'I@keystone:client', 'keystone.client', true) |
| 299 | salt.enforceState(saltMaster, 'I@keystone:client', 'keystone.client', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 300 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 301 | |
| 302 | // Install glance and ensure glusterfs clusters |
| 303 | //runSaltProcessStep(saltMaster, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 304 | salt.enforceState(saltMaster, 'I@glance:server and *01*', 'glance.server', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 305 | salt.enforceState(saltMaster, 'I@glance:server', 'glance.server', true) |
| 306 | salt.enforceState(saltMaster, 'I@glance:server', 'glusterfs.client', true) |
| 307 | |
| 308 | // Update fernet tokens before doing request on keystone server |
| 309 | salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true) |
| 310 | |
| 311 | // Check glance service |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 312 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 313 | |
| 314 | // Install and check nova service |
| 315 | //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1) |
Marek Celoud | 396ba54 | 2017-03-21 11:02:50 +0100 | [diff] [blame] | 316 | salt.enforceState(saltMaster, 'I@nova:controller and *01*', 'nova.controller', true) |
| 317 | salt.enforceState(saltMaster, 'I@nova:controller', 'nova.controller', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 318 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 319 | |
| 320 | // Install and check cinder service |
| 321 | //runSaltProcessStep(saltMaster, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 322 | salt.enforceState(saltMaster, 'I@cinder:controller and *01*', 'cinder', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 323 | salt.enforceState(saltMaster, 'I@cinder:controller', 'cinder', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 324 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 325 | |
| 326 | // Install neutron service |
| 327 | //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
Tomáš Kukrál | 575e38a | 2017-03-02 17:12:45 +0100 | [diff] [blame] | 328 | |
Marek Celoud | 396ba54 | 2017-03-21 11:02:50 +0100 | [diff] [blame] | 329 | salt.enforceState(saltMaster, 'I@neutron:server and *01*', 'neutron.server', true) |
| 330 | salt.enforceState(saltMaster, 'I@neutron:server', 'neutron.server', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 331 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 332 | |
| 333 | // Install heat service |
| 334 | //runSaltProcessStep(saltMaster, 'I@heat:server', 'state.sls', ['heat'], 1) |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 335 | salt.enforceState(saltMaster, 'I@heat:server and *01*', 'heat', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 336 | salt.enforceState(saltMaster, 'I@heat:server', 'heat', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 337 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 338 | |
Marek Celoud | ec7c0a9 | 2017-03-23 11:01:35 +0100 | [diff] [blame] | 339 | // Restart nova api |
| 340 | salt.runSaltProcessStep(saltMaster, 'I@nova:controller', 'service.restart', ['nova-api']) |
| 341 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | stage('Install OpenStack network') { |
| 345 | //orchestrate.installOpenstackMkNetwork(saltMaster, physical) |
| 346 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 347 | if (common.checkContains('INSTALL', 'contrail')) { |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 348 | // Install opencontrail database services |
| 349 | //runSaltProcessStep(saltMaster, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
Tomáš Kukrál | f8ac03b | 2017-03-10 15:08:22 +0100 | [diff] [blame] | 350 | try { |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 351 | salt.enforceState(saltMaster, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
Tomáš Kukrál | 0dccc89 | 2017-03-10 15:42:44 +0100 | [diff] [blame] | 352 | } catch (Exception e) { |
Jakub Josef | c719060 | 2017-03-14 10:43:56 +0100 | [diff] [blame] | 353 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*') |
Tomáš Kukrál | f8ac03b | 2017-03-10 15:08:22 +0100 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | try { |
| 357 | salt.enforceState(saltMaster, 'I@opencontrail:database', 'opencontrail.database', true) |
Tomáš Kukrál | 0dccc89 | 2017-03-10 15:42:44 +0100 | [diff] [blame] | 358 | } catch (Exception e) { |
Jakub Josef | c719060 | 2017-03-14 10:43:56 +0100 | [diff] [blame] | 359 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database') |
Tomáš Kukrál | f8ac03b | 2017-03-10 15:08:22 +0100 | [diff] [blame] | 360 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 361 | |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 362 | // Install opencontrail control services |
| 363 | //runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
Marek Celoud | 1a489a6 | 2017-03-14 13:46:41 +0100 | [diff] [blame] | 364 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Marek Celoud | 1465b54 | 2017-03-14 12:28:38 +0100 | [diff] [blame] | 365 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 366 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 367 | |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 368 | // Test opencontrail |
| 369 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true) |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 370 | } else if (common.checkContains('INSTALL', 'ovs')) { |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 371 | // Apply gateway |
| 372 | salt.runSaltProcessStep(saltMaster, 'I@neutron:gateway', 'state.apply', [], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 373 | } |
| 374 | |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 375 | // Pring information |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 376 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'], null, true) |
| 377 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | stage('Install OpenStack compute') { |
| 381 | //orchestrate.installOpenstackMkCompute(saltMaster, physical) |
| 382 | // Configure compute nodes |
Tomáš Kukrál | da26d90 | 2017-03-02 22:19:00 +0100 | [diff] [blame] | 383 | retry(2) { |
Tomáš Kukrál | 02cda9f | 2017-03-02 22:32:57 +0100 | [diff] [blame] | 384 | salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', [], null, true) |
Tomáš Kukrál | da26d90 | 2017-03-02 22:19:00 +0100 | [diff] [blame] | 385 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 386 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 387 | if (common.checkContains('INSTALL', 'contrail')) { |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 388 | // Provision opencontrail control services |
| 389 | salt.enforceState(saltMaster, 'I@opencontrail:database:id:1', 'opencontrail.client', true) |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 390 | // Provision opencontrail virtual routers |
Marek Celoud | feb6706 | 2017-03-13 11:01:43 +0100 | [diff] [blame] | 391 | salt.enforceState(saltMaster, 'I@opencontrail:compute', 'opencontrail.client', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 392 | |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 393 | salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'cmd.run', ['exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "'], null, true) |
| 394 | sleep(300) |
| 395 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 396 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 397 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 398 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 399 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 400 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 401 | if (common.checkContains('INSTALL', 'stacklight')) { |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 402 | stage('Install StackLight') { |
| 403 | // infra install |
| 404 | // Install the StackLight backends |
| 405 | salt.enforceState(saltMaster, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
| 406 | salt.enforceState(saltMaster, 'I@elasticsearch:server', 'elasticsearch.server', true) |
| 407 | |
| 408 | salt.enforceState(saltMaster, '*01* and I@influxdb:server', 'influxdb', true) |
| 409 | salt.enforceState(saltMaster, 'I@influxdb:server', 'influxdb', true) |
| 410 | |
| 411 | salt.enforceState(saltMaster, '*01* and I@kibana:server', 'kibana.server', true) |
| 412 | salt.enforceState(saltMaster, 'I@kibana:server', 'kibana.server', true) |
| 413 | |
| 414 | salt.enforceState(saltMaster, '*01* and I@grafana:server','grafana.server', true) |
| 415 | salt.enforceState(saltMaster, 'I@grafana:server','grafana.server', true) |
| 416 | |
| 417 | salt.enforceState(saltMaster, 'I@nagios:server', 'nagios.server', true) |
| 418 | salt.enforceState(saltMaster, 'I@elasticsearch:client', 'elasticsearch.client.service', true) |
| 419 | salt.enforceState(saltMaster, 'I@kibana:client', 'kibana.client.service', true) |
| 420 | // nw salt.enforceState('I@kibana:client or I@elasticsearch:client' --async service.restart salt-minion |
| 421 | |
| 422 | sleep(10) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 423 | |
Marek Celoud | 3fd4ea9 | 2017-03-10 11:36:01 +0100 | [diff] [blame] | 424 | salt.runSaltProcessStep(saltMaster, 'I@elasticsearch.client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true) |
| 425 | // salt.enforceState(saltMaster, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Marek Celoud | 481bc42 | 2017-03-10 12:13:19 +0100 | [diff] [blame] | 426 | salt.runSaltProcessStep(saltMaster, 'I@kibana.client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true) |
| 427 | // salt.enforceState(saltMaster, 'I@kibana:client', 'kibana.client', true) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 428 | |
| 429 | // install monitor |
| 430 | // Restart salt-minion to make sure that it uses the latest Jinja library |
| 431 | // no way: salt '*' --async service.restart salt-minion; sleep 15 |
| 432 | |
| 433 | // Start by flusing Salt Mine to make sure it is clean |
| 434 | // Also clean-up the grains files to make sure that we start from a clean state |
| 435 | // nw salt "*" mine.flush |
| 436 | // nw salt "*" file.remove /etc/salt/grains.d/collectd |
| 437 | // nw salt "*" file.remove /etc/salt/grains.d/grafana |
| 438 | // nw salt "*" file.remove /etc/salt/grains.d/heka |
| 439 | // nw salt "*" file.remove /etc/salt/grains.d/sensu |
| 440 | // nw salt "*" file.remove /etc/salt/grains |
| 441 | |
| 442 | // Install collectd, heka and sensu services on the nodes, this will also |
| 443 | // generate the metadata that goes into the grains and eventually into Salt Mine |
Tomáš Kukrál | 2aa3c47 | 2017-03-03 17:47:08 +0100 | [diff] [blame] | 444 | salt.enforceState(saltMaster, '*', 'collectd', true) |
Marek Celoud | d630341 | 2017-03-09 23:14:32 +0100 | [diff] [blame] | 445 | salt.enforceState(saltMaster, '*', 'salt.minion', true) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 446 | salt.enforceState(saltMaster, '*', 'heka', true) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 447 | |
| 448 | // Gather the Grafana metadata as grains |
| 449 | salt.enforceState(saltMaster, 'I@grafana:collector', 'grafana.collector', true) |
| 450 | |
| 451 | // Update Salt Mine |
| 452 | salt.enforceState(saltMaster, '*', 'salt.minion.grains', true) |
| 453 | salt.runSaltProcessStep(saltMaster, '*', 'saltutil.refresh_modules', [], null, true) |
| 454 | salt.runSaltProcessStep(saltMaster, '*', 'mine.update', [], null, true) |
| 455 | |
| 456 | sleep(5) |
| 457 | |
| 458 | // Update Heka |
| 459 | salt.enforceState(saltMaster, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true) |
| 460 | |
| 461 | // Update collectd |
| 462 | salt.enforceState(saltMaster, 'I@collectd:remote_client:enabled:True', 'collectd', true) |
| 463 | |
| 464 | // Update Nagios |
| 465 | salt.enforceState(saltMaster, 'I@nagios:server', 'nagios', true) |
| 466 | // Stop the Nagios service because the package starts it by default and it will |
| 467 | // started later only on the node holding the VIP address |
| 468 | salt.runSaltProcessStep(saltMaster, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 469 | |
| 470 | // Update Sensu |
Tomáš Kukrál | 1ef3da7 | 2017-03-06 14:44:00 +0100 | [diff] [blame] | 471 | // TODO for stacklight team, should be fixed in model |
| 472 | //salt.enforceState(saltMaster, 'I@sensu:server', 'sensu', true) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 473 | |
| 474 | // Finalize the configuration of Grafana (add the dashboards...) |
| 475 | salt.enforceState(saltMaster, 'I@grafana:client', 'grafana.client.service', true) |
| 476 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
Marek Celoud | a613ed0 | 2017-03-10 15:39:55 +0100 | [diff] [blame] | 477 | |
| 478 | salt.runSaltProcessStep(saltMaster, 'I@grafana.client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true) |
| 479 | // salt.enforceState(saltMaster, 'I@grafana:client and *01*', 'grafana.client', true) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 480 | |
| 481 | // Get the StackLight monitoring VIP addres |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 482 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 483 | //vip=${vip:=172.16.10.253} |
Tomáš Kukrál | edbb24c | 2017-03-10 16:10:29 +0100 | [diff] [blame] | 484 | def pillar = salt.getPillar(saltMaster, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | fafd659 | 2017-03-27 18:53:17 +0200 | [diff] [blame] | 485 | print(common.prettyPrint(pillar)) |
Tomáš Kukrál | aae889a | 2017-03-22 13:37:34 +0100 | [diff] [blame] | 486 | def stacklight_vip = pillar['return'][0].values()[0] |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 487 | |
Tomáš Kukrál | aae889a | 2017-03-22 13:37:34 +0100 | [diff] [blame] | 488 | if (stacklight_vip) { |
Tomáš Kukrál | 6412a8c | 2017-03-07 14:03:47 +0100 | [diff] [blame] | 489 | // (re)Start manually the services that are bound to the monitoring VIP |
Tomáš Kukrál | aae889a | 2017-03-22 13:37:34 +0100 | [diff] [blame] | 490 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
Tomáš Kukrál | 1b08c8c | 2017-03-07 16:51:49 +0100 | [diff] [blame] | 491 | salt.runSaltProcessStep(saltMaster, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true) |
| 492 | salt.runSaltProcessStep(saltMaster, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true) |
| 493 | salt.runSaltProcessStep(saltMaster, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true) |
| 494 | salt.runSaltProcessStep(saltMaster, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true) |
Tomáš Kukrál | aae889a | 2017-03-22 13:37:34 +0100 | [diff] [blame] | 495 | } else { |
| 496 | throw new Exception("Missing stacklight_vip") |
Tomáš Kukrál | 6412a8c | 2017-03-07 14:03:47 +0100 | [diff] [blame] | 497 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 498 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 499 | } |
| 500 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 501 | // |
| 502 | // Test |
| 503 | // |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 504 | def artifacts_dir = '_artifacts/' |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 505 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 506 | if (common.checkContains('TEST', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 507 | stage('Run k8s bootstrap tests') { |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 508 | def image = 'tomkukral/k8s-scripts' |
| 509 | def output_file = image.replaceAll('/', '-') |
| 510 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame^] | 511 | // run image |
| 512 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 513 | |
| 514 | // collect output |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 515 | sh "mkdir -p ${artifacts_dir}" |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame^] | 516 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 517 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 518 | sh "cat ${artifacts_dir}${output_file}" |
| 519 | |
| 520 | // collect artifacts |
| 521 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 522 | } |
| 523 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame^] | 524 | stage('Run k8s conformance e2e tests') { |
| 525 | //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE) |
| 526 | |
| 527 | def image = K8S_CONFORMANCE_IMAGE |
| 528 | def output_file = image.replaceAll('/', '-') |
| 529 | |
| 530 | // run image |
| 531 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
| 532 | |
| 533 | // collect output |
| 534 | sh "mkdir -p ${artifacts_dir}" |
| 535 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 536 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 537 | sh "cat ${artifacts_dir}${output_file}" |
| 538 | |
| 539 | // collect artifacts |
| 540 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 541 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 542 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 543 | |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 544 | if (common.checkContains('TEST', 'openstack')) { |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 545 | stage('Run OpenStack tests') { |
| 546 | test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK) |
| 547 | } |
| 548 | |
| 549 | stage('Copy Tempest results to config node') { |
| 550 | test.copyTempestResults(saltMaster) |
| 551 | } |
| 552 | } |
| 553 | |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 554 | stage('Finalize') { |
| 555 | try { |
| 556 | salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true) |
| 557 | } catch (Exception e) { |
| 558 | common.warningMsg('State apply failed but we should continue to run') |
| 559 | } |
| 560 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 561 | } catch (Throwable e) { |
| 562 | currentBuild.result = 'FAILURE' |
| 563 | throw e |
Tomáš Kukrál | 65fb5fd | 2017-03-02 14:56:49 +0100 | [diff] [blame] | 564 | } finally { |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 565 | |
Tomáš Kukrál | 96b12d5 | 2017-03-07 22:43:37 +0100 | [diff] [blame] | 566 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 567 | // |
| 568 | // Clean |
| 569 | // |
| 570 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 571 | if (STACK_TYPE == 'heat') { |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 572 | // send notification |
| 573 | common.sendNotification(currentBuild.result, HEAT_STACK_NAME, ["slack"]) |
| 574 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 575 | if (HEAT_STACK_DELETE.toBoolean() == true) { |
| 576 | common.errorMsg('Heat job cleanup triggered') |
| 577 | stage('Trigger cleanup job') { |
| 578 | build job: 'deploy-heat-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]] |
| 579 | } |
| 580 | } else { |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 581 | if (currentBuild.result == 'FAILURE') { |
| 582 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 583 | |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 584 | if (SALT_MASTER_URL) { |
| 585 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
| 586 | } |
Tomáš Kukrál | b908dac | 2017-03-07 18:58:35 +0100 | [diff] [blame] | 587 | } |
| 588 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 589 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 590 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 591 | } |
| 592 | } |
| 593 | } |