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 | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 52 | comps = [ |
| 53 | 'consul': [ |
| 54 | 'type': 'image', |
| 55 | 'upstream': upstreamReg, |
| 56 | 'name': 'consul', |
| 57 | 'digest': 'sha256:0dc990ff3c44d5b5395475bcc5ebdae4fc8b67f69e17942a8b9793b3df74d290' |
| 58 | ] |
| 59 | ] |
| 60 | } |
| 61 | |
| 62 | task fetchUpstreamImages { |
| 63 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } } |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 64 | } |
| 65 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 66 | // Switch Configuration Image |
| 67 | |
| 68 | task buildSwitchqImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 69 | commandLine "docker", 'build', '-t', 'cord-maas-switchq', './switchq' |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | task tagSwitchqImage(type: Exec) { |
| 73 | dependsOn buildSwitchqImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 74 | commandLine "docker", 'tag', 'cord-maas-switchq', "$targetReg/cord-maas-switchq:$targetTag" |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | task publishSwitchqImage(type: Exec) { |
| 78 | dependsOn tagSwitchqImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 79 | commandLine "docker", 'push', "$targetReg/cord-maas-switchq:$targetTag" |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | // Bootstrap Image |
| 83 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 84 | task buildBootstrapImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 85 | commandLine "docker", 'build', '-t', 'cord-maas-bootstrap', './bootstrap' |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 86 | } |
| 87 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 88 | task tagBootstrapImage(type: Exec) { |
| 89 | dependsOn buildBootstrapImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 90 | commandLine "docker", 'tag', 'cord-maas-bootstrap', "$targetReg/cord-maas-bootstrap:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 91 | } |
| 92 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 93 | task publishBootstrapImage(type: Exec) { |
| 94 | dependsOn tagBootstrapImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 95 | commandLine "docker", 'push', "$targetReg/cord-maas-bootstrap:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 96 | } |
| 97 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 98 | // IP Allocator Image |
| 99 | |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 100 | task buildAllocationImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 101 | commandLine "docker", 'build', '-t', 'cord-ip-allocator', './ip-allocator' |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | task tagAllocationImage(type: Exec) { |
David K. Bainbridge | f22dc06 | 2016-05-31 15:35:39 -0700 | [diff] [blame] | 105 | dependsOn buildAllocationImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 106 | commandLine "docker", 'tag', 'cord-ip-allocator', "$targetReg/cord-ip-allocator:$targetTag" |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | task publishAllocationImage(type: Exec) { |
David K. Bainbridge | f22dc06 | 2016-05-31 15:35:39 -0700 | [diff] [blame] | 110 | dependsOn tagAllocationImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 111 | commandLine "docker", 'push', "$targetReg/cord-ip-allocator:$targetTag" |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 112 | } |
| 113 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 114 | // Provisioner Image |
| 115 | |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 116 | task buildProvisionerImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 117 | commandLine "docker", 'build', '-t', 'cord-provisioner', './provisioner' |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | task tagProvisionerImage(type: Exec) { |
| 121 | dependsOn buildProvisionerImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 122 | commandLine "docker", 'tag', 'cord-provisioner', "$targetReg/cord-provisioner:$targetTag" |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | task publishProvisionerImage(type: Exec) { |
| 126 | dependsOn tagProvisionerImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 127 | commandLine "docker", 'push', "$targetReg/cord-provisioner:$targetTag" |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 128 | } |
| 129 | |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 130 | // Config Generator Image |
| 131 | |
| 132 | task buildConfigGeneratorImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 133 | commandLine "docker", 'build', '-t', 'config-generator', './config-generator' |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | task tagConfigGeneratorImage(type: Exec) { |
| 137 | dependsOn buildConfigGeneratorImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 138 | commandLine "docker", 'tag', 'config-generator', "$targetReg/config-generator:$targetTag" |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | task publishConfigGeneratorImage(type: Exec) { |
| 142 | dependsOn tagConfigGeneratorImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 143 | commandLine "docker", 'push', "$targetReg/config-generator:$targetTag" |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 144 | } |
| 145 | |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 146 | // Automation Image |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 147 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 148 | task buildAutomationImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 149 | commandLine "docker", 'build', '-t', "cord-maas-automation", "-f", "./automation/Dockerfile", "./automation" |
David K. Bainbridge | efa951d | 2016-05-26 10:54:25 -0700 | [diff] [blame] | 150 | } |
| 151 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 152 | task tagAutomationImage(type: Exec) { |
| 153 | dependsOn buildAutomationImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 154 | commandLine "docker", 'tag', 'cord-maas-automation', "$targetReg/cord-maas-automation:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 155 | } |
| 156 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 157 | task publishAutomationImage(type: Exec) { |
| 158 | dependsOn tagAutomationImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 159 | commandLine "docker", 'push', "$targetReg/cord-maas-automation:$targetTag" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 160 | } |
| 161 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 162 | // DHCP Harvester Images |
| 163 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 164 | task buildHarvesterImage(type: Exec) { |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 165 | commandLine "docker", 'build', '-t', "cord-dhcp-harvester", "./harvester" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | task tagHarvesterImage(type: Exec) { |
| 169 | dependsOn buildHarvesterImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 170 | commandLine "docker", 'tag', 'cord-dhcp-harvester', "$targetReg/cord-dhcp-harvester:$targetTag" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | task publishHarvesterImage(type: Exec) { |
| 174 | dependsOn tagHarvesterImage |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 175 | commandLine "docker", 'push', "$targetReg/cord-dhcp-harvester:$targetTag" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 179 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 180 | task updateDocker (type: Exec) { |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 181 | commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg" |
| 182 | } |
| 183 | |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 184 | // To be used to fetch upstream binaries, clone repos, etc. |
| 185 | task fetch(type: Exec) { |
| 186 | // this is where we fetch upstream artifacts that we do not need internet for the build phase" |
| 187 | // Placeholdr example: |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 188 | dependsOn fetchUpstreamImages |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 189 | commandLine "docker", "pull", "golang:alpine" |
| 190 | commandLine "docker", "pull", "python:2.7-alpine" |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | // To be used to generate all needed binaries that need to be present on the target |
| 194 | // as docker images in the local docker runner. |
| 195 | task buildImages { |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 196 | dependsOn buildBootstrapImage |
| 197 | dependsOn buildHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 198 | dependsOn buildAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 199 | dependsOn buildAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 200 | dependsOn buildProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 201 | dependsOn buildConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 202 | dependsOn buildSwitchqImage |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | task tagImages { |
| 206 | dependsOn tagBootstrapImage |
| 207 | dependsOn tagHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 208 | dependsOn tagAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 209 | dependsOn tagAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 210 | dependsOn tagProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 211 | dependsOn tagConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 212 | dependsOn tagSwitchqImage |
Zsolt Haraszti | 2a792f6 | 2016-05-12 17:49:02 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | task publish { |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 216 | //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] | 217 | comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } } |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 218 | dependsOn publishBootstrapImage |
| 219 | dependsOn publishHarvesterImage |
David K. Bainbridge | 9d1e02d | 2016-06-22 09:22:16 -0700 | [diff] [blame] | 220 | dependsOn publishAutomationImage |
David K. Bainbridge | 8bc905c | 2016-05-31 14:07:10 -0700 | [diff] [blame] | 221 | dependsOn publishAllocationImage |
David K. Bainbridge | f0da873 | 2016-06-01 16:15:37 -0700 | [diff] [blame] | 222 | dependsOn publishProvisionerImage |
gunjan5 | e9bdd1d | 2016-07-13 14:59:33 -0700 | [diff] [blame] | 223 | dependsOn publishConfigGeneratorImage |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 224 | dependsOn publishSwitchqImage |
David K. Bainbridge | efa951d | 2016-05-26 10:54:25 -0700 | [diff] [blame] | 225 | } |
| 226 | |
David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 227 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 228 | // ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
| 229 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 230 | List.metaClass.asParam = { prefix, sep -> |
| 231 | if (delegate.size() == 0) { |
| 232 | "" |
| 233 | } |
| 234 | String result = "--" + prefix + "=" |
| 235 | String p = "" |
| 236 | delegate.each { |
| 237 | result += p + "${it}" |
| 238 | p = sep |
| 239 | } |
| 240 | result |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 241 | } |
| 242 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 243 | List.metaClass.p = { value, name -> |
| 244 | if (value != null && value != "") { |
| 245 | delegate << name + "=" + value |
| 246 | } else { |
| 247 | delegate |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | List.metaClass.p = { spec -> |
| 252 | if (spec != null && spec != "") { |
| 253 | delegate += spec |
| 254 | } else { |
| 255 | delegate |
| 256 | } |
| 257 | } |
| 258 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 259 | task prime (type: Exec) { |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 260 | println "Using deployment config: $deployConfig" |
| 261 | File configFile = new File(deployConfig) |
| 262 | def yaml = new Yaml() |
| 263 | def config = yaml.load(configFile.newReader()) |
| 264 | |
| 265 | executable = "ansible-playbook" |
| 266 | args = ["-i", config.seedServer.ip + ','] |
| 267 | |
| 268 | if ( config.seedServer.user != null && config.seedServer.user != "" ) { |
| 269 | args = args << "--user=$config.seedServer.user" |
| 270 | } |
| 271 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 272 | if ( config.debug ) { |
| 273 | args = args << "-vvvv" |
| 274 | } |
| 275 | |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 276 | def extraVars = [] |
| 277 | if (config.seedServer) { |
| 278 | extraVars = extraVars.p(config.seedServer.extraVars) |
| 279 | .p(config.seedServer.password, "ansible_ssh_pass") |
| 280 | .p(config.seedServer.sudoPassword, "ansible_sudo_pass") |
| 281 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 282 | .p(config.seedServer.management_ip, "management_ip") |
David K. Bainbridge | e80fd39 | 2016-08-19 15:46:19 -0700 | [diff] [blame] | 283 | .p(config.seedServer.management_gw, "management_gw") |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 284 | .p(config.seedServer.management_bc, "management_bc") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 285 | .p(config.seedServer.management_network, "management_network") |
| 286 | .p(config.seedServer.management_iface, "management_iface") |
| 287 | .p(config.seedServer.external_ip, "external_ip") |
David K. Bainbridge | e80fd39 | 2016-08-19 15:46:19 -0700 | [diff] [blame] | 288 | .p(config.seedServer.external_gw, "external_gw") |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 289 | .p(config.seedServer.external_bc, "external_bc") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 290 | .p(config.seedServer.external_network, "external_network") |
| 291 | .p(config.seedServer.external_iface, "external_iface") |
| 292 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 293 | .p(config.seedServer.fabric_network, "fabric_network") |
| 294 | .p(config.seedServer.fabric_iface, "fabric_iface") |
David K. Bainbridge | de51ce5 | 2016-08-22 13:54:24 -0700 | [diff] [blame] | 295 | .p(config.seedServer.fabric_iface_spec, "fabric_iface_spec") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 296 | .p(config.seedServer.domain, "domain") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 297 | .p(config.seedServer.virtualbox_support, "virtualbox_support") |
| 298 | .p(config.seedServer.power_helper_user, "power_helper_user") |
| 299 | .p(config.seedServer.power_helper_host, "power_helper_host") |
| 300 | .p(config.seedServer.port, "ansible_ssh_port") |
David K. Bainbridge | f418170 | 2016-06-17 14:44:03 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | if (config.otherServers) { |
| 304 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 305 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 306 | .p(config.otherServers.role, "prov_role") |
| 307 | } |
| 308 | |
| 309 | if (config.docker) { |
| 310 | extraVars = extraVars.p(config.docker.registry, "docker_registry") |
| 311 | .p(config.docker.imageVersion, "docker_image_version") |
| 312 | } |
| 313 | |
| 314 | def skipTags = [].p(config.seedServer.skipTags) |
| 315 | |
| 316 | args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "prime-node.yml" |
| 317 | } |
| 318 | |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 319 | task deployBase(type: Exec) { |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 320 | println "Using deployment config: $deployConfig" |
| 321 | File configFile = new File(deployConfig) |
| 322 | def yaml = new Yaml() |
| 323 | def config = yaml.load(configFile.newReader()) |
| 324 | |
| 325 | executable = "ansible-playbook" |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 326 | args = ["-i", config.seedServer.ip + ','] |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 327 | |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 328 | if ( config.seedServer.user != null && config.seedServer.user != "" ) { |
| 329 | args = args << "--user=$config.seedServer.user" |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 330 | } |
| 331 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 332 | |
| 333 | if ( config.debug ) { |
| 334 | args = args << "-vvvv" |
| 335 | } |
| 336 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 337 | def extraVars = [] |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 338 | if (config.seedServer) { |
| 339 | extraVars = extraVars.p(config.seedServer.extraVars) |
| 340 | .p(config.seedServer.password, "ansible_ssh_pass") |
| 341 | .p(config.seedServer.sudoPassword, "ansible_sudo_pass") |
| 342 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 343 | .p(config.seedServer.management_ip, "management_ip") |
David K. Bainbridge | e80fd39 | 2016-08-19 15:46:19 -0700 | [diff] [blame] | 344 | .p(config.seedServer.management_gw, "management_gw") |
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 | e80fd39 | 2016-08-19 15:46:19 -0700 | [diff] [blame] | 348 | .p(config.seedServer.external_gw, "external_gw") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 349 | .p(config.seedServer.external_network, "external_network") |
| 350 | .p(config.seedServer.external_iface, "external_iface") |
| 351 | .p(config.seedServer.fabric_ip, "fabric_ip") |
| 352 | .p(config.seedServer.fabric_network, "fabric_network") |
| 353 | .p(config.seedServer.fabric_iface, "fabric_iface") |
David K. Bainbridge | de51ce5 | 2016-08-22 13:54:24 -0700 | [diff] [blame] | 354 | .p(config.seedServer.fabric_iface_spec, "fabric_iface_spec") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 355 | .p(config.seedServer.domain, "domain") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 356 | .p(config.seedServer.virtualbox_support, "virtualbox_support") |
David K. Bainbridge | c82a446 | 2016-06-14 12:39:01 -0700 | [diff] [blame] | 357 | .p(config.seedServer.power_helper_user, "power_helper_user") |
| 358 | .p(config.seedServer.power_helper_host, "power_helper_host") |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 359 | .p(config.seedServer.port, "ansible_ssh_port") |
David K. Bainbridge | 6ea57c1 | 2016-06-06 23:29:12 -0700 | [diff] [blame] | 360 | } |
| 361 | |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 362 | if (config.otherServers) { |
| 363 | extraVars = extraVars.p(config.otherServers.location, "prov_location") |
| 364 | .p(config.otherServers.rolesPath, "prov_role_path") |
| 365 | .p(config.otherServers.role, "prov_role") |
| 366 | } |
| 367 | |
David K. Bainbridge | 97ee805 | 2016-06-14 00:52:07 -0700 | [diff] [blame] | 368 | if (config.docker) { |
| 369 | extraVars = extraVars.p(config.docker.registry, "docker_registry") |
| 370 | .p(config.docker.imageVersion, "docker_image_version") |
| 371 | } |
| 372 | |
David K. Bainbridge | 13c765c | 2016-05-26 11:24:22 -0700 | [diff] [blame] | 373 | def skipTags = [].p(config.seedServer.skipTags) |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 374 | |
| 375 | 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] | 376 | } |
alshabib | 462f625 | 2016-08-29 16:15:28 -0700 | [diff] [blame] | 377 | |
| 378 | prime.dependsOn { |
| 379 | updateDocker |
| 380 | } |
| 381 | |
| 382 | tasks.addRule(new DockerFetchRule(project)) |
| 383 | tasks.addRule(new DockerPublishRule(project, project(':maas').prime)) |
| 384 | tasks.addRule(new DockerTagRule(project)) |
| 385 | |
| 386 | |