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 | * |
| 36 | */ |
| 37 | |
| 38 | git = new com.mirantis.mk.Git() |
| 39 | openstack = new com.mirantis.mk.Openstack() |
| 40 | salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 41 | |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 42 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 43 | timestamps { |
| 44 | node { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 45 | try { |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 46 | |
| 47 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 48 | // |
| 49 | // Prepare machines |
| 50 | // |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 51 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 52 | stage ('Create infrastructure') { |
| 53 | if (STACK_TYPE == 'heat') { |
| 54 | // value defaults |
| 55 | def openstackCloud |
| 56 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 57 | def openstackEnv = "${env.WORKSPACE}/venv" |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 58 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 59 | if (HEAT_STACK_NAME == '') { |
| 60 | HEAT_STACK_NAME = BUILD_TAG |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 61 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 62 | |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 63 | // set description |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 64 | currentBuild.description = "${HEAT_STACK_NAME}" |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 65 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 66 | // get templates |
| 67 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
| 68 | |
| 69 | // create openstack env |
| 70 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 71 | openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
| 72 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 73 | |
| 74 | // launch stack |
| 75 | if (HEAT_STACK_REUSE == 'false') { |
| 76 | stage('Launch new Heat stack') { |
| 77 | // create stack |
| 78 | envParams = [ |
| 79 | 'instance_zone': HEAT_STACK_ZONE, |
| 80 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 81 | ] |
| 82 | openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // get SALT_MASTER_URL |
| 87 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv) |
Tomáš Kukrál | aeb5c92 | 2017-03-02 17:00:48 +0100 | [diff] [blame] | 88 | currentBuild.description = "${HEAT_STACK_NAME}: ${saltMasterHost}" |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 89 | SALT_MASTER_URL = "http://${saltMasterHost}:8088" |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 90 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 91 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 92 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 93 | // |
| 94 | // Connect to Salt master |
| 95 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 96 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 97 | def saltMaster |
| 98 | stage('Connect to Salt API') { |
| 99 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 100 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 101 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 102 | // |
| 103 | // Install |
| 104 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 105 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 106 | if (INSTALL.toLowerCase().contains('core')) { |
| 107 | stage('Install core infrastructure') { |
| 108 | // salt.master, reclass |
| 109 | // refresh_pillar |
| 110 | // sync_all |
| 111 | // linux,openssh,salt.minion.ntp |
Tomáš Kukrá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 | //orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 114 | salt.enforceState(saltMaster, 'I@salt:master', ['salt.master', 'reclass'], true) |
| 115 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', null, true) |
| 116 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', null, true) |
| 117 | salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 118 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 119 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 120 | if (INSTALL.toLowerCase().contains('kvm')) { |
| 121 | //orchestrate.installInfraKvm(saltMaster) |
| 122 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar') |
| 123 | salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all') |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 124 | |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 125 | 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] | 126 | salt.enforceState(saltMaster, 'I@salt:control', 'libvirt', true) |
| 127 | salt.enforceState(saltMaster, 'I@salt:control', 'salt.control', true) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 128 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 129 | sleep(300) |
| 130 | |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 131 | salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.refresh_pillar', null, true) |
| 132 | salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.sync_all', null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 133 | |
| 134 | // workaround - install apt-transport-https |
| 135 | salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'pkg.install', ['apt-transport-https refresh=True']) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 136 | salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | //orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 140 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['salt-key'], null, true) |
| 141 | salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'test.version', null, true) |
| 142 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true) |
| 143 | salt.runSaltProcessStep(saltMaster, 'I@reclass:storage', 'reclass.inventory', null, true) |
| 144 | salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'state.show_top', null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
| 148 | // install k8s |
| 149 | if (INSTALL.toLowerCase().contains('k8s')) { |
| 150 | stage('Install Kubernetes infra') { |
| 151 | //orchestrate.installOpenstackMcpInfra(saltMaster) |
| 152 | |
| 153 | // Comment nameserver |
| 154 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"]) |
| 155 | |
| 156 | // Install glusterfs |
| 157 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service']) |
| 158 | |
| 159 | // Install keepalived |
| 160 | salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['keepalived']) |
| 161 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived']) |
| 162 | |
| 163 | // Check the keepalived VIPs |
| 164 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 165 | |
| 166 | // Setup glusterfs |
| 167 | salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['glusterfs.server.setup']) |
| 168 | salt.runSaltProcessStep(saltMaster, 'ctl02*', 'state.sls', ['glusterfs.server.setup']) |
| 169 | salt.runSaltProcessStep(saltMaster, 'ctl03*', 'state.sls', ['glusterfs.server.setup']) |
| 170 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status']) |
| 171 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status']) |
| 172 | |
| 173 | // Install haproxy |
| 174 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'state.sls', ['haproxy']) |
| 175 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 176 | |
| 177 | // Install docker |
| 178 | salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host']) |
| 179 | salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps']) |
| 180 | |
| 181 | // Install bird |
| 182 | salt.runSaltProcessStep(saltMaster, 'I@bird:server', 'state.sls', ['bird']) |
| 183 | |
| 184 | // Install etcd |
| 185 | salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service']) |
| 186 | salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health']) |
| 187 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 188 | } |
| 189 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 190 | stage('Install Kubernetes control') { |
| 191 | //orchestrate.installOpenstackMcpControl(saltMaster) |
Tomáš Kukrál | 06c27a9 | 2017-03-01 16:21:46 +0100 | [diff] [blame] | 192 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 193 | // Install Kubernetes pool and Calico |
| 194 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool']) |
| 195 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 196 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 197 | // Setup etcd server |
| 198 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 199 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 200 | // Run k8s without master.setup |
| 201 | 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] | 202 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 203 | // Run k8s master setup |
| 204 | salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['kubernetes.master.setup']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 205 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 206 | // Revert comment nameserver |
| 207 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"]) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 208 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 209 | // Set route |
| 210 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 211 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 212 | // Restart kubelet |
| 213 | salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 218 | // install openstack |
| 219 | if (INSTALL.toLowerCase().contains('openstack')) { |
| 220 | // install Infra and control, tests, ... |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 221 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 222 | stage('Install OpenStack infra') { |
| 223 | //orchestrate.installOpenstackMkInfra(saltMaster, physical) |
| 224 | |
| 225 | // Install keepaliveds |
| 226 | //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1) |
| 227 | salt.enforceState(saltMaster, 'ctl01*', 'keepalived', true) |
| 228 | salt.enforceState(saltMaster, 'I@keepalived:cluster', 'keepalived', true) |
| 229 | |
| 230 | // Check the keepalived VIPs |
| 231 | salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 232 | |
| 233 | // Install glusterfs |
| 234 | salt.enforceState(saltMaster, 'I@glusterfs:server', 'glusterfs.server.service', true) |
| 235 | |
| 236 | //runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1) |
| 237 | if (INSTALL.toLowerCase().contains('kvm')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 238 | salt.enforceState(saltMaster, 'kvm01*', 'glusterfs.server.setup', true) |
| 239 | salt.enforceState(saltMaster, 'kvm02*', 'glusterfs.server.setup', true) |
| 240 | salt.enforceState(saltMaster, 'kvm03*', 'glusterfs.server.setup', true) |
Tomáš Kukrál | bad54bb | 2017-03-02 15:46:20 +0100 | [diff] [blame] | 241 | } else { |
| 242 | salt.enforceState(saltMaster, 'ctl01*', 'glusterfs.server.setup', true) |
| 243 | salt.enforceState(saltMaster, 'ctl02*', 'glusterfs.server.setup', true) |
| 244 | salt.enforceState(saltMaster, 'ctl03*', 'glusterfs.server.setup', true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 245 | } |
| 246 | |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 247 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true) |
| 248 | salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 249 | |
| 250 | // Install rabbitmq |
| 251 | salt.enforceState(saltMaster, 'I@rabbitmq:server', 'rabbitmq', true) |
| 252 | |
| 253 | // Check the rabbitmq status |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame^] | 254 | salt.runSaltProcessStep(saltMaster, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 255 | |
| 256 | // Install galera |
| 257 | salt.enforceState(saltMaster, 'I@galera:master', 'galera', true) |
| 258 | salt.enforceState(saltMaster, 'I@galera:slave', 'galera', true) |
| 259 | |
| 260 | // Check galera status |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame^] | 261 | salt.runSaltProcessStep(saltMaster, 'I@galera:master', 'mysql.status') |
| 262 | salt.runSaltProcessStep(saltMaster, 'I@galera:slave', 'mysql.status') |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 263 | |
| 264 | // Install haproxy |
| 265 | salt.enforceState(saltMaster, 'I@haproxy:proxy', 'haproxy', true) |
Ales Komarek | 96ff9ed | 2017-03-02 18:37:51 +0100 | [diff] [blame^] | 266 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 267 | salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 268 | |
| 269 | // Install memcached |
| 270 | salt.enforceState(saltMaster, 'I@memcached:server', 'memcached', true) |
| 271 | |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 272 | } |
| 273 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 274 | stage('Install OpenStack control') { |
| 275 | //orchestrate.installOpenstackMkControl(saltMaster) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 276 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 277 | // setup keystone service |
| 278 | //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
| 279 | salt.enforceState(saltMaster, 'ctl01*', 'keystone.server', true) |
| 280 | salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true) |
| 281 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 282 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 283 | // keystone:client must be called locally |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 284 | salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 285 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 286 | |
| 287 | // Install glance and ensure glusterfs clusters |
| 288 | //runSaltProcessStep(saltMaster, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
| 289 | salt.enforceState(saltMaster, 'ctl01*', 'glance.server', true) |
| 290 | salt.enforceState(saltMaster, 'I@glance:server', 'glance.server', true) |
| 291 | salt.enforceState(saltMaster, 'I@glance:server', 'glusterfs.client', true) |
| 292 | |
| 293 | // Update fernet tokens before doing request on keystone server |
| 294 | salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true) |
| 295 | |
| 296 | // Check glance service |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 297 | 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] | 298 | |
| 299 | // Install and check nova service |
| 300 | //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1) |
| 301 | salt.enforceState(saltMaster, 'ctl01*', 'nova', true) |
| 302 | salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 303 | 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] | 304 | |
| 305 | // Install and check cinder service |
| 306 | //runSaltProcessStep(saltMaster, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
| 307 | salt.enforceState(saltMaster, 'ctl01*', 'cinder', true) |
| 308 | salt.enforceState(saltMaster, 'I@cinder:controller', 'cinder', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 309 | 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] | 310 | |
| 311 | // Install neutron service |
| 312 | //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
Tomáš Kukrál | 575e38a | 2017-03-02 17:12:45 +0100 | [diff] [blame] | 313 | if (INSTALL.toLowerCase().contains('kvm')) { |
| 314 | salt.enforceState(saltMaster, 'ntw01*', 'neutron', true) |
| 315 | } else { |
| 316 | salt.enforceState(saltMaster, 'ctl01*', 'neutron', true) |
| 317 | } |
| 318 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 319 | salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 320 | 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] | 321 | |
| 322 | // Install heat service |
| 323 | //runSaltProcessStep(saltMaster, 'I@heat:server', 'state.sls', ['heat'], 1) |
| 324 | salt.enforceState(saltMaster, 'ctl01*', 'heat', true) |
| 325 | salt.enforceState(saltMaster, 'I@heat:server', 'heat', true) |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 326 | 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] | 327 | |
| 328 | // Install horizon dashboard |
| 329 | salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true) |
| 330 | salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true) |
| 331 | |
| 332 | } |
| 333 | |
| 334 | stage('Install OpenStack network') { |
| 335 | //orchestrate.installOpenstackMkNetwork(saltMaster, physical) |
| 336 | |
| 337 | // Install opencontrail database services |
| 338 | //runSaltProcessStep(saltMaster, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
| 339 | salt.enforceState(saltMaster, 'ntw01*', 'opencontrail.database', true) |
| 340 | salt.enforceState(saltMaster, 'I@opencontrail:database', 'opencontrail.database', true) |
| 341 | |
| 342 | // Install opencontrail control services |
| 343 | //runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
| 344 | salt.enforceState(saltMaster, 'ntw01*', 'opencontrail', true) |
| 345 | salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail', true) |
| 346 | |
| 347 | // Provision opencontrail control services |
| 348 | if (INSTALL.toLowerCase().contains('kvm')) { |
Tomáš Kukrál | 575e38a | 2017-03-02 17:12:45 +0100 | [diff] [blame] | 349 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw01 --host_ip 10.167.4.21 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
| 350 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw02 --host_ip 10.167.4.22 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
| 351 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 10.167.4.20 --api_server_port 8082 --host_name ntw03 --host_ip 10.167.4.23 --router_asn 64512 --admin_password password --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
| 352 | } else { |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 353 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl01 --host_ip 172.16.10.101 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
| 354 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl02 --host_ip 172.16.10.102 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
| 355 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl03 --host_ip 172.16.10.103 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | // Test opencontrail |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 359 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true) |
| 360 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'], null, true) |
| 361 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | stage('Install OpenStack compute') { |
| 365 | //orchestrate.installOpenstackMkCompute(saltMaster, physical) |
| 366 | // Configure compute nodes |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 367 | salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', null, true) |
| 368 | salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 369 | |
| 370 | // Provision opencontrail virtual routers |
| 371 | if (INSTALL.toLowerCase().contains('kvm')) { |
Tomáš Kukrál | 575e38a | 2017-03-02 17:12:45 +0100 | [diff] [blame] | 372 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp001 --host_ip 10.167.4.101 --api_server_ip 10.167.4.21 --oper add --admin_user admin --admin_password password --admin_tenant_name admin'], null, true) |
| 373 | } else { |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 374 | salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp01 --host_ip 172.16.10.105 --api_server_ip 172.16.10.254 --oper add --admin_user admin --admin_password workshop --admin_tenant_name admin'], null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 375 | } |
| 376 | |
Tomáš Kukrál | cbdb1d0 | 2017-03-02 16:08:51 +0100 | [diff] [blame] | 377 | salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'system.reboot', null, true) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 378 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 379 | } |
| 380 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 381 | // |
| 382 | // Test |
| 383 | // |
| 384 | |
| 385 | if (TEST.toLowerCase().contains('k8s')) { |
| 386 | stage('Run k8s bootstrap tests') { |
| 387 | orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts') |
| 388 | } |
| 389 | |
| 390 | stage('Run k8s conformance e2e tests') { |
| 391 | orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE) |
| 392 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 393 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 394 | |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 395 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 396 | } catch (Throwable e) { |
| 397 | currentBuild.result = 'FAILURE' |
| 398 | throw e |
Tomáš Kukrál | 65fb5fd | 2017-03-02 14:56:49 +0100 | [diff] [blame] | 399 | } finally { |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 400 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 401 | // |
| 402 | // Clean |
| 403 | // |
| 404 | |
| 405 | if (HEAT_STACK_DELETE == 'true' && STACK_TYPE == 'heat') { |
| 406 | stage('Trigger cleanup job') { |
| 407 | build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]] |
| 408 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 409 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 410 | } |
| 411 | } |
| 412 | } |