Jonathan Hart | 93956f5 | 2017-08-22 13:12:42 -0700 | [diff] [blame] | 1 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 2 | /* |
Jonathan Hart | 93956f5 | 2017-08-22 13:12:42 -0700 | [diff] [blame] | 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Jonathan Hart | 93956f5 | 2017-08-22 13:12:42 -0700 | [diff] [blame] | 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
Jonathan Hart | 93956f5 | 2017-08-22 13:12:42 -0700 | [diff] [blame] | 17 | |
| 18 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 19 | import org.opencord.gradle.rules.* |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 20 | import org.yaml.snakeyaml.Yaml |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 21 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 22 | allprojects { |
| 23 | apply plugin: 'base' |
| 24 | apply plugin: 'de.gesellix.docker' |
| 25 | //apply plugin: 'com.tmiyamon.config' |
| 26 | |
| 27 | docker { |
| 28 | // dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock' |
| 29 | // dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376' |
| 30 | // certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default" |
| 31 | // authConfigPlain = [ |
| 32 | // "username" : "joe", |
| 33 | // "password" : "some-pw-as-needed", |
| 34 | // "email" : "joe@acme.com", |
| 35 | // "serveraddress" : "https://index.docker.io/v1/" |
| 36 | // ] |
| 37 | } |
| 38 | } |
| 39 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 40 | ext { |
| 41 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 42 | // Upstream registry to simplify filling out the comps table below |
| 43 | upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io' |
| 44 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 45 | // Deployment target config file (yaml format); this can be overwritten from the command line |
| 46 | // using the -PdeployConfig=<file-path> syntax. |
| 47 | deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml' |
David K. Bainbridge | 19b8d27 | 2016-05-26 21:20:43 -0700 | [diff] [blame] | 48 | |
David K. Bainbridge | c4e0fc5 | 2016-11-14 12:03:35 -0800 | [diff] [blame] | 49 | println "Using deployment config: $deployConfig" |
| 50 | File configFile = new File(deployConfig) |
| 51 | def yaml = new Yaml() |
| 52 | config = yaml.load(configFile.newReader()) |
| 53 | |
| 54 | // Target registry to be used to publish docker images needed for deployment |
| 55 | targetReg = project.hasProperty('targetReg') |
| 56 | ? project.getProperty('targetReg') |
| 57 | : config.docker && config.docker.registry |
| 58 | ? config.docker.registry |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 59 | : config.headnode.ip |
| 60 | ? config.headnode.ip + ":5000" |
David K. Bainbridge | c9cacd3 | 2016-11-15 15:10:06 -0800 | [diff] [blame] | 61 | : 'localhost:5000' |
David K. Bainbridge | c4e0fc5 | 2016-11-14 12:03:35 -0800 | [diff] [blame] | 62 | |
| 63 | // The tag used to tag the docker images push to the target registry |
| 64 | targetTag = project.hasProperty('targetTag') |
| 65 | ? project.getProperty('targetTag') |
| 66 | : config.docker && config.docker.imageVersion |
| 67 | ? config.docker.imageVersion |
| 68 | : 'candidate' |
| 69 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 70 | comps = [ |
| 71 | 'consul': [ |
| 72 | 'type': 'image', |
| 73 | 'upstream': upstreamReg, |
| 74 | 'name': 'consul', |
| 75 | 'digest': 'sha256:0dc990ff3c44d5b5395475bcc5ebdae4fc8b67f69e17942a8b9793b3df74d290' |
| 76 | ] |
| 77 | ] |
| 78 | } |
| 79 | |
| 80 | task fetchUpstreamImages { |
| 81 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } } |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 82 | } |
| 83 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 84 | // Switch Configuration Image |
| 85 | |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 86 | def getBuildTimestamp() { |
| 87 | def cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")) |
| 88 | def date = cal.getTime() |
David K. Bainbridge | 151e845 | 2016-12-19 23:05:51 -0800 | [diff] [blame] | 89 | def formattedDate = date.format("yyyy-MM-dd'T'HH:mm:ssZ") |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 90 | return formattedDate |
| 91 | } |
| 92 | |
David K. Bainbridge | 151e845 | 2016-12-19 23:05:51 -0800 | [diff] [blame] | 93 | def getCommitDate = { -> |
| 94 | def stdOut = new ByteArrayOutputStream() |
| 95 | exec { |
| 96 | commandLine "git", "log", "--pretty=format:%cd", "--date=format:%FT%T%z", "-n", "1" |
| 97 | standardOutput = stdOut |
| 98 | } |
| 99 | return stdOut.toString().trim() |
| 100 | } |
| 101 | |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 102 | def getCommitHash = { -> |
| 103 | def hashStdOut = new ByteArrayOutputStream() |
| 104 | exec { |
David K. Bainbridge | 151e845 | 2016-12-19 23:05:51 -0800 | [diff] [blame] | 105 | commandLine "git", "log", "--pretty=format:%H", "-n", "1" |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 106 | standardOutput = hashStdOut |
| 107 | } |
| 108 | return hashStdOut.toString().trim() |
| 109 | } |
| 110 | |
David K. Bainbridge | d4e3f62 | 2017-01-12 14:07:54 -0800 | [diff] [blame] | 111 | def isModified = { -> |
| 112 | def statusOut = new ByteArrayOutputStream() |
| 113 | def branchesOut = new ByteArrayOutputStream() |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 114 | exec { |
David K. Bainbridge | d4e3f62 | 2017-01-12 14:07:54 -0800 | [diff] [blame] | 115 | commandLine "bash", "-c", "repo --color=never --no-pager status . | tail -n +2 | wc -l" |
| 116 | standardOutput = statusOut |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 117 | } |
David K. Bainbridge | d4e3f62 | 2017-01-12 14:07:54 -0800 | [diff] [blame] | 118 | exec { |
| 119 | commandLine "bash", "-c", "repo --color=never --no-pager branches | wc -l" |
| 120 | standardOutput = branchesOut |
| 121 | } |
| 122 | def statusVal = statusOut.toString().trim() |
| 123 | def branchesVal = branchesOut.toString().trim() |
| 124 | |
| 125 | return statusVal != "0" || branchesVal != "0" |
| 126 | } |
| 127 | |
| 128 | def getBranchName = { -> |
| 129 | def stdout = new ByteArrayOutputStream() |
| 130 | exec { |
| 131 | commandLine "bash", "-c", "repo --color=never --no-pager info -l -o | grep 'Manifest branch:' | awk '{print \$NF}'" |
| 132 | standardOutput = stdout |
| 133 | } |
| 134 | def val = stdout.toString().trim() |
| 135 | if ( isModified() != "0" ) { |
| 136 | val += '[modified]' |
| 137 | } |
| 138 | return val |
David K. Bainbridge | de0d926 | 2016-09-13 20:12:06 -0700 | [diff] [blame] | 139 | } |
David K. Bainbridge | 6e23ac8 | 2016-12-07 12:55:41 -0800 | [diff] [blame] | 140 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 141 | task buildSwitchqImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 142 | workingDir 'switchq' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 143 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | task publishSwitchqImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 147 | workingDir 'switchq' |
| 148 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 149 | } |
| 150 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 151 | // IP Allocator Image |
| 152 | |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 153 | task buildAllocationImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 154 | workingDir 'ip-allocator' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 155 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | task publishAllocationImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 159 | workingDir 'ip-allocator' |
| 160 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 161 | } |
| 162 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 163 | // Provisioner Image |
| 164 | |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 165 | task buildProvisionerImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 166 | workingDir 'provisioner' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 167 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | task publishProvisionerImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 171 | workingDir 'provisioner' |
| 172 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 173 | } |
| 174 | |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 175 | // Config Generator Image |
| 176 | |
| 177 | task buildConfigGeneratorImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 178 | workingDir 'config-generator' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 179 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | task publishConfigGeneratorImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 183 | workingDir 'config-generator' |
| 184 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 185 | } |
| 186 | |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 187 | // Automation Image |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 188 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 189 | task buildAutomationImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 190 | workingDir 'automation' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 191 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 192 | } |
| 193 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 194 | task publishAutomationImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 195 | workingDir 'automation' |
| 196 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 197 | } |
| 198 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 199 | // DHCP Harvester Images |
| 200 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 201 | task buildHarvesterImage(type: Exec) { |
David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame] | 202 | workingDir 'harvester' |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 203 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'build' |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | task publishHarvesterImage(type: Exec) { |
David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 207 | workingDir 'harvester' |
| 208 | commandLine 'make', "DOCKER_TAG=$targetTag", "DOCKER_REGISTRY=$targetReg", 'publish' |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 212 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 213 | task updateDocker (type: Exec) { |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 214 | commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg" |
| 215 | } |
| 216 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 217 | // To be used to fetch upstream binaries, clone repos, etc. |
| 218 | task fetch(type: Exec) { |
| 219 | // this is where we fetch upstream artifacts that we do not need internet for the build phase" |
| 220 | // Placeholdr example: |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 221 | dependsOn fetchUpstreamImages |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 222 | commandLine "docker", "pull", "golang:alpine" |
| 223 | commandLine "docker", "pull", "python:2.7-alpine" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // To be used to generate all needed binaries that need to be present on the target |
| 227 | // as docker images in the local docker runner. |
| 228 | task buildImages { |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 229 | dependsOn buildHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 230 | dependsOn buildAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 231 | dependsOn buildAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 232 | dependsOn buildProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 233 | dependsOn buildConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 234 | dependsOn buildSwitchqImage |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 237 | task publish { |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 238 | //FIXME: This works because the upstream project primes the nodes before running this. |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 239 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } } |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 240 | dependsOn publishHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 241 | dependsOn publishAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 242 | dependsOn publishAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 243 | dependsOn publishProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 244 | dependsOn publishConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 245 | dependsOn publishSwitchqImage |
David K. Bainbridge | efa951d | 2016-05-26 10:54:25 -0700 | [diff] [blame] | 246 | } |
| 247 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 248 | // ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 249 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 250 | List.metaClass.asParam = { prefix, sep -> |
| 251 | if (delegate.size() == 0) { |
| 252 | "" |
| 253 | } |
| 254 | String result = "--" + prefix + "=" |
| 255 | String p = "" |
| 256 | delegate.each { |
| 257 | result += p + "${it}" |
| 258 | p = sep |
| 259 | } |
| 260 | result |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 261 | } |
| 262 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 263 | List.metaClass.p = { value, name -> |
| 264 | if (value != null && value != "") { |
| 265 | delegate << name + "=" + value |
| 266 | } else { |
| 267 | delegate |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | List.metaClass.p = { spec -> |
| 272 | if (spec != null && spec != "") { |
| 273 | delegate += spec |
| 274 | } else { |
| 275 | delegate |
| 276 | } |
| 277 | } |
| 278 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 279 | task prime (type: Exec) { |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 280 | executable = "ansible-playbook" |
Zack Williams | 642388d | 2017-04-12 22:39:15 -0700 | [diff] [blame] | 281 | args = ["-i", '../genconfig/cord-inv'] |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 282 | |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 283 | if ( config.headnode.ansible_user != null && config.headnode.ansible_user != "" ) { |
| 284 | args = args << "--user=$config.headnode.ansible_user" |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 285 | } |
| 286 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 287 | if ( config.debug ) { |
| 288 | args = args << "-vvvv" |
| 289 | } |
| 290 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 291 | def extraVars = [] |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 292 | if (config.common) { |
| 293 | extraVars = extraVars.p(config.common.extraVars) |
| 294 | .p(config.headnode.ansible_ssh_pass, "ansible_ssh_pass") |
| 295 | .p(config.headnode.ansible_become_pass, "ansible_become_pass") |
| 296 | .p(config.headnode.ansible_ssh_port, "ansible_ssh_port") |
| 297 | .p(config.common.fabric_ip, "fabric_ip") |
| 298 | .p(config.common.fabric_range_low, "fabric_range_low") |
| 299 | .p(config.common.fabric_range_high, "fabric_range_high") |
| 300 | .p(config.common.management_ip, "management_ip") |
| 301 | .p(config.common.management_range_low, "management_range_low") |
| 302 | .p(config.common.management_range_high, "management_range_high") |
| 303 | .p(config.common.management_gw, "management_gw") |
| 304 | .p(config.common.management_bc, "management_bc") |
| 305 | .p(config.common.management_network, "management_network") |
| 306 | .p(config.common.management_iface, "management_iface") |
| 307 | .p(config.common.external_ip, "external_ip") |
| 308 | .p(config.common.external_gw, "external_gw") |
| 309 | .p(config.common.external_bc, "external_bc") |
| 310 | .p(config.common.external_network, "external_network") |
| 311 | .p(config.common.external_iface, "external_iface") |
| 312 | .p(config.common.fabric_iface, "fabric_iface") |
| 313 | .p(config.common.domain, "domain") |
| 314 | .p(config.common.virtualbox_support, "virtualbox_support") |
| 315 | .p(config.common.power_helper_user, "power_helper_user") |
| 316 | .p(config.common.power_helper_host, "power_helper_host") |
saikrishna edupuganti | e86ddab | 2017-07-23 21:04:06 -0700 | [diff] [blame] | 317 | .p(config.common.kernel_opts, "kernel_opts") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 318 | } |
| 319 | |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 320 | if (config.passwords) { |
| 321 | extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node") |
| 322 | .p(config.passwords.maas_admin, "password_maas_admin") |
| 323 | .p(config.passwords.maas_user, "password_maas_user") |
| 324 | } |
| 325 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 326 | if (config.otherServers) { |
| 327 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 328 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 329 | .p(config.otherServers.role, "prov_role") |
| 330 | } |
| 331 | |
David K. Bainbridge | c4e0fc5 | 2016-11-14 12:03:35 -0800 | [diff] [blame] | 332 | extraVars = extraVars.p("$targetReg", "deploy_docker_registry") |
| 333 | .p("$targetTag", "deploy_docker_tag") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 334 | |
David K. Bainbridge | 6e23ac8 | 2016-12-07 12:55:41 -0800 | [diff] [blame] | 335 | // the password set on the compute node is skipped because this is being run against the |
| 336 | // head node and we don't want to change the head node password as this node was manualy |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 337 | // set up. |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 338 | def skipTags = [].p(config.common.skipTags).p('set_compute_node_password') |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 339 | |
| 340 | args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "prime-node.yml" |
| 341 | } |
| 342 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 343 | task deployBase(type: Exec) { |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 344 | executable = "ansible-playbook" |
Zack Williams | 642388d | 2017-04-12 22:39:15 -0700 | [diff] [blame] | 345 | args = ["-i", '../genconfig/cord-inv'] |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 346 | |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 347 | if ( config.headnode.ansible_user != null && config.headnode.ansible_user != "" ) { |
| 348 | args = args << "--user=$config.headnode.ansible_user" |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 349 | } |
| 350 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 351 | if ( config.debug ) { |
| 352 | args = args << "-vvvv" |
| 353 | } |
| 354 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 355 | def extraVars = [] |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 356 | if (config.common) { |
| 357 | extraVars = extraVars.p(config.common.extraVars) |
| 358 | .p(config.headnode.ansible_ssh_pass, "ansible_ssh_pass") |
| 359 | .p(config.headnode.ansible_become_pass, "ansible_become_pass") |
| 360 | .p(config.headnode.ansible_ssh_port, "ansible_ssh_port") |
| 361 | .p(config.common.fabric_ip, "fabric_ip") |
| 362 | .p(config.common.fabric_range_low, "fabric_range_low") |
| 363 | .p(config.common.fabric_range_high, "fabric_range_high") |
| 364 | .p(config.common.management_ip, "management_ip") |
| 365 | .p(config.common.management_range_low, "management_range_low") |
| 366 | .p(config.common.management_range_high, "management_range_high") |
| 367 | .p(config.common.management_gw, "management_gw") |
| 368 | .p(config.common.management_network, "management_network") |
| 369 | .p(config.common.management_iface, "management_iface") |
| 370 | .p(config.common.external_ip, "external_ip") |
| 371 | .p(config.common.external_gw, "external_gw") |
| 372 | .p(config.common.external_network, "external_network") |
| 373 | .p(config.common.external_iface, "external_iface") |
| 374 | .p(config.common.fabric_iface, "fabric_iface") |
| 375 | .p(config.common.domain, "domain") |
| 376 | .p(config.common.virtualbox_support, "virtualbox_support") |
| 377 | .p(config.common.power_helper_user, "power_helper_user") |
| 378 | .p(config.common.power_helper_host, "power_helper_host") |
saikrishna edupuganti | e86ddab | 2017-07-23 21:04:06 -0700 | [diff] [blame] | 379 | .p(config.common.kernel_opts, "kernel_opts") |
David K. Bainbridge | 6ea57c1 | 2016-06-06 23:29:12 -0700 | [diff] [blame] | 380 | } |
| 381 | |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 382 | if (config.passwords) { |
| 383 | extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node") |
| 384 | .p(config.passwords.maas_admin, "password_maas_admin") |
| 385 | .p(config.passwords.maas_user, "password_maas_user") |
| 386 | } |
| 387 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 388 | if (config.otherServers) { |
| 389 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 390 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 391 | .p(config.otherServers.role, "prov_role") |
| 392 | } |
| 393 | |
David K. Bainbridge | c4e0fc5 | 2016-11-14 12:03:35 -0800 | [diff] [blame] | 394 | extraVars = extraVars.p("$targetReg", "deploy_docker_registry") |
| 395 | .p("$targetTag", "deploy_docker_tag") |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 396 | |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 397 | // the password set on the compute node is skipped because this is being run against the |
| 398 | // head node and we don't want to change the head node password as this node was manualy |
| 399 | // set up. |
Zack Williams | b55e8ef | 2017-02-01 10:54:36 -0700 | [diff] [blame] | 400 | def skipTags = [].p(config.common.skipTags).p('set_compute_node_password') |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 401 | |
| 402 | 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] | 403 | } |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 404 | |
| 405 | prime.dependsOn { |
| 406 | updateDocker |
| 407 | } |
| 408 | |
| 409 | tasks.addRule(new DockerFetchRule(project)) |
| 410 | tasks.addRule(new DockerPublishRule(project, project(':maas').prime)) |
| 411 | tasks.addRule(new DockerTagRule(project)) |
| 412 | |
| 413 | |