Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 the original author or authors. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 16 | import org.opencord.gradle.rules.* |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 17 | import org.yaml.snakeyaml.Yaml |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 18 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 19 | allprojects { |
| 20 | apply plugin: 'base' |
| 21 | apply plugin: 'de.gesellix.docker' |
| 22 | //apply plugin: 'com.tmiyamon.config' |
| 23 | |
| 24 | docker { |
| 25 | // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock' |
| 26 | // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376' |
| 27 | // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default" |
| 28 | // authConfigPlain = [ |
| 29 | // "username" : "joe", |
| 30 | // "password" : "some-pw-as-needed", |
| 31 | // "email" : "joe@acme.com", |
| 32 | // "serveraddress" : "https://index.docker.io/v1/" |
| 33 | // ] |
| 34 | } |
| 35 | } |
| 36 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 37 | ext { |
| 38 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 39 | // Upstream registry to simplify filling out the comps table below |
| 40 | upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io' |
| 41 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 42 | // Target registry to be used to publish docker images needed for deployment |
| 43 | targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000' |
| 44 | |
| 45 | // The tag used to tag the docker images push to the target registry |
| 46 | targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate' |
| 47 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 48 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 49 | // using the -PdeployConfig=<file-path> syntax. |
| 50 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 51 | |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 52 | dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin' |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 53 | |
| 54 | comps = [ |
| 55 | 'consul': [ |
| 56 | 'type': 'image', |
| 57 | 'upstream': upstreamReg, |
| 58 | 'name': 'consul', |
| 59 | 'digest': 'sha256:0dc990ff3c44d5b5395475bcc5ebdae4fc8b67f69e17942a8b9793b3df74d290' |
| 60 | ] |
| 61 | ] |
| 62 | } |
| 63 | |
| 64 | task fetchUpstreamImages { |
| 65 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } } |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 66 | } |
| 67 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 68 | // Switch Configuration Image |
| 69 | |
| 70 | task buildSwitchqImage(type: Exec) { |
| 71 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-maas-switchq', './switchq' |
| 72 | } |
| 73 | |
| 74 | task tagSwitchqImage(type: Exec) { |
| 75 | dependsOn buildSwitchqImage |
| 76 | commandLine "$dockerPath/docker", 'tag', 'cord-maas-switchq', "$targetReg/cord-maas-switchq:$targetTag" |
| 77 | } |
| 78 | |
| 79 | task publishSwitchqImage(type: Exec) { |
| 80 | dependsOn tagSwitchqImage |
| 81 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-maas-switchq:$targetTag" |
| 82 | } |
| 83 | |
| 84 | // Bootstrap Image |
| 85 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 86 | task buildBootstrapImage(type: Exec) { |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 87 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-maas-bootstrap', './bootstrap' |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 88 | } |
| 89 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 90 | task tagBootstrapImage(type: Exec) { |
| 91 | dependsOn buildBootstrapImage |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 92 | commandLine "$dockerPath/docker", 'tag', 'cord-maas-bootstrap', "$targetReg/cord-maas-bootstrap:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 93 | } |
| 94 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 95 | task publishBootstrapImage(type: Exec) { |
| 96 | dependsOn tagBootstrapImage |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 97 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-maas-bootstrap:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 98 | } |
| 99 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 100 | // IP Allocator Image |
| 101 | |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 102 | task buildAllocationImage(type: Exec) { |
David K. Bainbridge | f22dc06 | 2016-05-31 15:35:39 -0700 | [diff] [blame] | 103 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-ip-allocator', './ip-allocator' |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | task tagAllocationImage(type: Exec) { |
David K. Bainbridge | f22dc06 | 2016-05-31 15:35:39 -0700 | [diff] [blame] | 107 | dependsOn buildAllocationImage |
| 108 | commandLine "$dockerPath/docker", 'tag', 'cord-ip-allocator', "$targetReg/cord-ip-allocator:$targetTag" |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | task publishAllocationImage(type: Exec) { |
David K. Bainbridge | f22dc06 | 2016-05-31 15:35:39 -0700 | [diff] [blame] | 112 | dependsOn tagAllocationImage |
| 113 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-ip-allocator:$targetTag" |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 114 | } |
| 115 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 116 | // Provisioner Image |
| 117 | |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 118 | task buildProvisionerImage(type: Exec) { |
David K. Bainbridge | d86d96d | 2016-06-01 17:28:46 -0700 | [diff] [blame] | 119 | commandLine "$dockerPath/docker", 'build', '-t', 'cord-provisioner', './provisioner' |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | task tagProvisionerImage(type: Exec) { |
| 123 | dependsOn buildProvisionerImage |
| 124 | commandLine "$dockerPath/docker", 'tag', 'cord-provisioner', "$targetReg/cord-provisioner:$targetTag" |
| 125 | } |
| 126 | |
| 127 | task publishProvisionerImage(type: Exec) { |
| 128 | dependsOn tagProvisionerImage |
| 129 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-provisioner:$targetTag" |
| 130 | } |
| 131 | |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 132 | // Config Generator Image |
| 133 | |
| 134 | task buildConfigGeneratorImage(type: Exec) { |
| 135 | commandLine "$dockerPath/docker", 'build', '-t', 'config-generator', './config-generator' |
| 136 | } |
| 137 | |
| 138 | task tagConfigGeneratorImage(type: Exec) { |
| 139 | dependsOn buildConfigGeneratorImage |
| 140 | commandLine "$dockerPath/docker", 'tag', 'config-generator', "$targetReg/config-generator:$targetTag" |
| 141 | } |
| 142 | |
| 143 | task publishConfigGeneratorImage(type: Exec) { |
| 144 | dependsOn tagConfigGeneratorImage |
| 145 | commandLine "$dockerPath/docker", 'push', "$targetReg/config-generator:$targetTag" |
| 146 | } |
| 147 | |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 148 | // Automation Image |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 149 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 150 | task buildAutomationImage(type: Exec) { |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 151 | commandLine "$dockerPath/docker", 'build', '-t', "cord-maas-automation", "-f", "./automation/Dockerfile", "./automation" |
David K. Bainbridge | efa951d | 2016-05-26 10:54:25 -0700 | [diff] [blame] | 152 | } |
| 153 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 154 | task tagAutomationImage(type: Exec) { |
| 155 | dependsOn buildAutomationImage |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 156 | commandLine "$dockerPath/docker", 'tag', 'cord-maas-automation', "$targetReg/cord-maas-automation:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 157 | } |
| 158 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 159 | task publishAutomationImage(type: Exec) { |
| 160 | dependsOn tagAutomationImage |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 161 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-maas-automation:$targetTag" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 162 | } |
| 163 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 164 | // DHCP Harvester Images |
| 165 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 166 | task buildHarvesterImage(type: Exec) { |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 167 | commandLine "$dockerPath/docker", 'build', '-t', "cord-dhcp-harvester", "./harvester" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | task tagHarvesterImage(type: Exec) { |
| 171 | dependsOn buildHarvesterImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 172 | commandLine "$dockerPath/docker", 'tag', 'cord-dhcp-harvester', "$targetReg/cord-dhcp-harvester:$targetTag" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | task publishHarvesterImage(type: Exec) { |
| 176 | dependsOn tagHarvesterImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 177 | commandLine "$dockerPath/docker", 'push', "$targetReg/cord-dhcp-harvester:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 181 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 182 | task updateDocker (type: Exec) { |
| 183 | commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg" |
| 184 | } |
| 185 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 186 | // To be used to fetch upstream binaries, clone repos, etc. |
| 187 | task fetch(type: Exec) { |
| 188 | // this is where we fetch upstream artifacts that we do not need internet for the build phase" |
| 189 | // Placeholdr example: |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 190 | dependsOn fetchUpstreamImages |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 191 | commandLine "$dockerPath/docker", "pull", "golang:alpine" |
| 192 | commandLine "$dockerPath/docker", "pull", "python:2.7-alpine" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | // To be used to generate all needed binaries that need to be present on the target |
| 196 | // as docker images in the local docker runner. |
| 197 | task buildImages { |
David K. Bainbridge | 3951678 | 2016-08-09 18:11:37 -0600 | [diff] [blame] | 198 | dependsOn fetch |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 199 | dependsOn buildBootstrapImage |
| 200 | dependsOn buildHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 201 | dependsOn buildAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 202 | dependsOn buildAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 203 | dependsOn buildProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 204 | dependsOn buildConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 205 | dependsOn buildSwitchqImage |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | task tagImages { |
| 209 | dependsOn tagBootstrapImage |
| 210 | dependsOn tagHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 211 | dependsOn tagAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 212 | dependsOn tagAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 213 | dependsOn tagProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 214 | dependsOn tagConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 215 | dependsOn tagSwitchqImage |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | task publish { |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 219 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } } |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 220 | dependsOn publishBootstrapImage |
| 221 | dependsOn publishHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 222 | dependsOn publishAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 223 | dependsOn publishAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 224 | dependsOn publishProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 225 | dependsOn publishConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 226 | dependsOn publishSwitchqImage |
David K. Bainbridge | efa951d | 2016-05-26 10:54:25 -0700 | [diff] [blame] | 227 | } |
| 228 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 229 | tasks.addRule(new DockerFetchRule(project)) |
| 230 | tasks.addRule(new DockerPublishRule(project)) |
| 231 | tasks.addRule(new DockerTagRule(project)) |
| 232 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 233 | // ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 234 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 235 | List.metaClass.asParam = { prefix, sep -> |
| 236 | if (delegate.size() == 0) { |
| 237 | "" |
| 238 | } |
| 239 | String result = "--" + prefix + "=" |
| 240 | String p = "" |
| 241 | delegate.each { |
| 242 | result += p + "${it}" |
| 243 | p = sep |
| 244 | } |
| 245 | result |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 246 | } |
| 247 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 248 | List.metaClass.p = { value, name -> |
| 249 | if (value != null && value != "") { |
| 250 | delegate << name + "=" + value |
| 251 | } else { |
| 252 | delegate |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | List.metaClass.p = { spec -> |
| 257 | if (spec != null && spec != "") { |
| 258 | delegate += spec |
| 259 | } else { |
| 260 | delegate |
| 261 | } |
| 262 | } |
| 263 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 264 | task prime (type: Exec) { |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 265 | dependsOn updateDocker |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 266 | println "Using deployment config: $deployConfig" |
| 267 | File configFile = new File(deployConfig) |
| 268 | def yaml = new Yaml() |
| 269 | def config = yaml.load(configFile.newReader()) |
| 270 | |
| 271 | executable = "ansible-playbook" |
| 272 | args = ["-i", config.seedServer.ip + ','] |
| 273 | |
| 274 | if ( config.seedServer.user != null && config.seedServer.user != "" ) { |
| 275 | args = args << "--user=$config.seedServer.user" |
| 276 | } |
| 277 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame^] | 278 | if ( config.debug ) { |
| 279 | args = args << "-vvvv" |
| 280 | } |
| 281 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 282 | def extraVars = [] |
| 283 | if (config.seedServer) { |
| 284 | extraVars = extraVars.p(config.seedServer.extraVars) |
| 285 | .p(config.seedServer.password, "ansible_ssh_pass") |
| 286 | .p(config.seedServer.sudoPassword, "ansible_sudo_pass") |
| 287 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 288 | .p(config.seedServer.management_ip, "management_ip") |
| 289 | .p(config.seedServer.management_network, "management_network") |
| 290 | .p(config.seedServer.management_iface, "management_iface") |
| 291 | .p(config.seedServer.external_ip, "external_ip") |
| 292 | .p(config.seedServer.external_network, "external_network") |
| 293 | .p(config.seedServer.external_iface, "external_iface") |
| 294 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 295 | .p(config.seedServer.fabric_network, "fabric_network") |
| 296 | .p(config.seedServer.fabric_iface, "fabric_iface") |
| 297 | .p(config.seedServer.domain, "domain") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 298 | .p(config.seedServer.virtualbox_support, "virtualbox_support") |
| 299 | .p(config.seedServer.power_helper_user, "power_helper_user") |
| 300 | .p(config.seedServer.power_helper_host, "power_helper_host") |
| 301 | .p(config.seedServer.port, "ansible_ssh_port") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | if (config.otherServers) { |
| 305 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 306 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 307 | .p(config.otherServers.role, "prov_role") |
| 308 | } |
| 309 | |
| 310 | if (config.docker) { |
| 311 | extraVars = extraVars.p(config.docker.registry, "docker_registry") |
| 312 | .p(config.docker.imageVersion, "docker_image_version") |
| 313 | } |
| 314 | |
| 315 | def skipTags = [].p(config.seedServer.skipTags) |
| 316 | |
| 317 | args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "prime-node.yml" |
| 318 | } |
| 319 | |
David K. Bainbridge | 23a4945 | 2016-07-06 15:59:09 -0700 | [diff] [blame] | 320 | task deployBase (type: Exec) { |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 321 | println "Using deployment config: $deployConfig" |
| 322 | File configFile = new File(deployConfig) |
| 323 | def yaml = new Yaml() |
| 324 | def config = yaml.load(configFile.newReader()) |
| 325 | |
| 326 | executable = "ansible-playbook" |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 327 | args = ["-i", config.seedServer.ip + ','] |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 328 | |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 329 | if ( config.seedServer.user != null && config.seedServer.user != "" ) { |
| 330 | args = args << "--user=$config.seedServer.user" |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 331 | } |
| 332 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame^] | 333 | |
| 334 | if ( config.debug ) { |
| 335 | args = args << "-vvvv" |
| 336 | } |
| 337 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 338 | def extraVars = [] |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 339 | if (config.seedServer) { |
| 340 | extraVars = extraVars.p(config.seedServer.extraVars) |
| 341 | .p(config.seedServer.password, "ansible_ssh_pass") |
| 342 | .p(config.seedServer.sudoPassword, "ansible_sudo_pass") |
| 343 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 344 | .p(config.seedServer.management_ip, "management_ip") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 345 | .p(config.seedServer.management_network, "management_network") |
| 346 | .p(config.seedServer.management_iface, "management_iface") |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 347 | .p(config.seedServer.external_ip, "external_ip") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 348 | .p(config.seedServer.external_network, "external_network") |
| 349 | .p(config.seedServer.external_iface, "external_iface") |
| 350 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 351 | .p(config.seedServer.fabric_network, "fabric_network") |
| 352 | .p(config.seedServer.fabric_iface, "fabric_iface") |
| 353 | .p(config.seedServer.domain, "domain") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 354 | .p(config.seedServer.virtualbox_support, "virtualbox_support") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 355 | .p(config.seedServer.power_helper_user, "power_helper_user") |
| 356 | .p(config.seedServer.power_helper_host, "power_helper_host") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 357 | .p(config.seedServer.port, "ansible_ssh_port") |
David K. Bainbridge | 6ea57c1 | 2016-06-06 23:29:12 -0700 | [diff] [blame] | 358 | } |
| 359 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 360 | if (config.otherServers) { |
| 361 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 362 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 363 | .p(config.otherServers.role, "prov_role") |
| 364 | } |
| 365 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 366 | if (config.docker) { |
| 367 | extraVars = extraVars.p(config.docker.registry, "docker_registry") |
| 368 | .p(config.docker.imageVersion, "docker_image_version") |
| 369 | } |
| 370 | |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 371 | def skipTags = [].p(config.seedServer.skipTags) |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 372 | |
| 373 | args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "head-node.yml" |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 374 | } |