blob: aa869e59ce14956981a7a232c0386956efd83864 [file] [log] [blame]
Zsolt Haraszti2a792f62016-05-12 17:49:02 -07001/*
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. Bainbridge59bdb542016-07-01 11:07:45 -070016import org.opencord.gradle.rules.*
David K. Bainbridge10b0c112016-05-24 13:17:23 -070017import org.yaml.snakeyaml.Yaml
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070018
David K. Bainbridge59bdb542016-07-01 11:07:45 -070019allprojects {
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 Haraszti2a792f62016-05-12 17:49:02 -070037ext {
38
David K. Bainbridge59bdb542016-07-01 11:07:45 -070039 // Upstream registry to simplify filling out the comps table below
40 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
41
David K. Bainbridge10b0c112016-05-24 13:17:23 -070042 // Deployment target config file (yaml format); this can be overwritten from the command line
43 // using the -PdeployConfig=<file-path> syntax.
44 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
David K. Bainbridge19b8d272016-05-26 21:20:43 -070045
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -080046 println "Using deployment config: $deployConfig"
47 File configFile = new File(deployConfig)
48 def yaml = new Yaml()
49 config = yaml.load(configFile.newReader())
50
51 // Target registry to be used to publish docker images needed for deployment
52 targetReg = project.hasProperty('targetReg')
53 ? project.getProperty('targetReg')
54 : config.docker && config.docker.registry
55 ? config.docker.registry
David K. Bainbridgec9cacd32016-11-15 15:10:06 -080056 : config.seedServer.ip
57 ? config.seedServer.ip + ":5000"
58 : 'localhost:5000'
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -080059
60 // The tag used to tag the docker images push to the target registry
61 targetTag = project.hasProperty('targetTag')
62 ? project.getProperty('targetTag')
63 : config.docker && config.docker.imageVersion
64 ? config.docker.imageVersion
65 : 'candidate'
66
David K. Bainbridge59bdb542016-07-01 11:07:45 -070067 comps = [
68 'consul': [
69 'type': 'image',
70 'upstream': upstreamReg,
71 'name': 'consul',
72 'digest': 'sha256:0dc990ff3c44d5b5395475bcc5ebdae4fc8b67f69e17942a8b9793b3df74d290'
73 ]
74 ]
75}
76
77task fetchUpstreamImages {
78 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "fetch" + name } }
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070079}
80
David K. Bainbridge97ee8052016-06-14 00:52:07 -070081// Switch Configuration Image
82
David K. Bainbridgede0d9262016-09-13 20:12:06 -070083def getBuildTimestamp() {
84 def cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
85 def date = cal.getTime()
86 def formattedDate = date.format("yyyy-MM-dd'T'HH:mm:ss.ss'Z'")
87 return formattedDate
88}
89
90def getCommitHash = { ->
91 def hashStdOut = new ByteArrayOutputStream()
92 exec {
93 commandLine "git", "rev-parse", "HEAD"
94 standardOutput = hashStdOut
95 }
96 return hashStdOut.toString().trim()
97}
98
99def getBranchName = { ->
100 def branchStdOut = new ByteArrayOutputStream()
101 exec {
102 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
103 standardOutput = branchStdOut
104 }
105 return branchStdOut.toString().trim()
106}
107
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700108task buildSwitchqImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700109 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-maas-switchq', './switchq'
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700110}
111
112task tagSwitchqImage(type: Exec) {
113 dependsOn buildSwitchqImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700114 commandLine "docker", 'tag', 'cord-maas-switchq', "$targetReg/cord-maas-switchq:$targetTag"
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700115}
116
117task publishSwitchqImage(type: Exec) {
118 dependsOn tagSwitchqImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700119 commandLine "docker", 'push', "$targetReg/cord-maas-switchq:$targetTag"
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700120}
121
122// Bootstrap Image
123
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700124task buildBootstrapImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700125 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-maas-bootstrap', './bootstrap'
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700126}
127
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700128task tagBootstrapImage(type: Exec) {
129 dependsOn buildBootstrapImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700130 commandLine "docker", 'tag', 'cord-maas-bootstrap', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700131}
132
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700133task publishBootstrapImage(type: Exec) {
134 dependsOn tagBootstrapImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700135 commandLine "docker", 'push', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700136}
137
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700138// IP Allocator Image
139
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700140task buildAllocationImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700141 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-ip-allocator', './ip-allocator'
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700142}
143
144task tagAllocationImage(type: Exec) {
David K. Bainbridgef22dc062016-05-31 15:35:39 -0700145 dependsOn buildAllocationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700146 commandLine "docker", 'tag', 'cord-ip-allocator', "$targetReg/cord-ip-allocator:$targetTag"
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700147}
148
149task publishAllocationImage(type: Exec) {
David K. Bainbridgef22dc062016-05-31 15:35:39 -0700150 dependsOn tagAllocationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700151 commandLine "docker", 'push', "$targetReg/cord-ip-allocator:$targetTag"
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700152}
153
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700154// Provisioner Image
155
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700156task buildProvisionerImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700157 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-provisioner', './provisioner'
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700158}
159
160task tagProvisionerImage(type: Exec) {
161 dependsOn buildProvisionerImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700162 commandLine "docker", 'tag', 'cord-provisioner', "$targetReg/cord-provisioner:$targetTag"
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700163}
164
165task publishProvisionerImage(type: Exec) {
166 dependsOn tagProvisionerImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700167 commandLine "docker", 'push', "$targetReg/cord-provisioner:$targetTag"
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700168}
169
gunjan5e9bdd1d2016-07-13 14:59:33 -0700170// Config Generator Image
171
172task buildConfigGeneratorImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700173 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'config-generator', './config-generator'
gunjan5e9bdd1d2016-07-13 14:59:33 -0700174}
175
176task tagConfigGeneratorImage(type: Exec) {
177 dependsOn buildConfigGeneratorImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700178 commandLine "docker", 'tag', 'config-generator', "$targetReg/config-generator:$targetTag"
gunjan5e9bdd1d2016-07-13 14:59:33 -0700179}
180
181task publishConfigGeneratorImage(type: Exec) {
182 dependsOn tagConfigGeneratorImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700183 commandLine "docker", 'push', "$targetReg/config-generator:$targetTag"
gunjan5e9bdd1d2016-07-13 14:59:33 -0700184}
185
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700186// Automation Image
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700187
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700188task buildAutomationImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700189 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', "cord-maas-automation", "-f", "./automation/Dockerfile", "./automation"
David K. Bainbridgeefa951d2016-05-26 10:54:25 -0700190}
191
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700192task tagAutomationImage(type: Exec) {
193 dependsOn buildAutomationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700194 commandLine "docker", 'tag', 'cord-maas-automation', "$targetReg/cord-maas-automation:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700195}
196
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700197task publishAutomationImage(type: Exec) {
198 dependsOn tagAutomationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700199 commandLine "docker", 'push', "$targetReg/cord-maas-automation:$targetTag"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700200}
201
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700202// DHCP Harvester Images
203
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700204task buildHarvesterImage(type: Exec) {
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700205 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', "cord-dhcp-harvester", "./harvester"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700206}
207
208task tagHarvesterImage(type: Exec) {
209 dependsOn buildHarvesterImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700210 commandLine "docker", 'tag', 'cord-dhcp-harvester', "$targetReg/cord-dhcp-harvester:$targetTag"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700211}
212
213task publishHarvesterImage(type: Exec) {
214 dependsOn tagHarvesterImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700215 commandLine "docker", 'push', "$targetReg/cord-dhcp-harvester:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700216}
217
218// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
219
alshabib462f6252016-08-29 16:15:28 -0700220task updateDocker (type: Exec) {
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700221 commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg"
222}
223
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700224// To be used to fetch upstream binaries, clone repos, etc.
225task fetch(type: Exec) {
226 // this is where we fetch upstream artifacts that we do not need internet for the build phase"
227 // Placeholdr example:
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700228 dependsOn fetchUpstreamImages
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700229 commandLine "docker", "pull", "golang:alpine"
230 commandLine "docker", "pull", "python:2.7-alpine"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700231}
232
233// To be used to generate all needed binaries that need to be present on the target
234// as docker images in the local docker runner.
235task buildImages {
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700236 dependsOn buildBootstrapImage
237 dependsOn buildHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700238 dependsOn buildAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700239 dependsOn buildAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700240 dependsOn buildProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700241 dependsOn buildConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700242 dependsOn buildSwitchqImage
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700243}
244
245task tagImages {
246 dependsOn tagBootstrapImage
247 dependsOn tagHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700248 dependsOn tagAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700249 dependsOn tagAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700250 dependsOn tagProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700251 dependsOn tagConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700252 dependsOn tagSwitchqImage
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700253}
254
255task publish {
alshabib462f6252016-08-29 16:15:28 -0700256 //FIXME: This works because the upstream project primes the nodes before running this.
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700257 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } }
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700258 dependsOn publishBootstrapImage
259 dependsOn publishHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700260 dependsOn publishAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700261 dependsOn publishAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700262 dependsOn publishProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700263 dependsOn publishConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700264 dependsOn publishSwitchqImage
David K. Bainbridgeefa951d2016-05-26 10:54:25 -0700265}
266
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700267
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700268// ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~
269
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700270List.metaClass.asParam = { prefix, sep ->
271 if (delegate.size() == 0) {
272 ""
273 }
274 String result = "--" + prefix + "="
275 String p = ""
276 delegate.each {
277 result += p + "${it}"
278 p = sep
279 }
280 result
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700281}
282
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700283List.metaClass.p = { value, name ->
284 if (value != null && value != "") {
285 delegate << name + "=" + value
286 } else {
287 delegate
288 }
289}
290
291List.metaClass.p = { spec ->
292 if (spec != null && spec != "") {
293 delegate += spec
294 } else {
295 delegate
296 }
297}
298
alshabib462f6252016-08-29 16:15:28 -0700299task prime (type: Exec) {
David K. Bainbridgef4181702016-06-17 14:44:03 -0700300 executable = "ansible-playbook"
301 args = ["-i", config.seedServer.ip + ',']
302
303 if ( config.seedServer.user != null && config.seedServer.user != "" ) {
304 args = args << "--user=$config.seedServer.user"
305 }
306
David K. Bainbridge5ba01a92016-08-16 14:58:31 -0700307 if ( config.debug ) {
308 args = args << "-vvvv"
309 }
310
David K. Bainbridgef4181702016-06-17 14:44:03 -0700311 def extraVars = []
312 if (config.seedServer) {
313 extraVars = extraVars.p(config.seedServer.extraVars)
314 .p(config.seedServer.password, "ansible_ssh_pass")
315 .p(config.seedServer.sudoPassword, "ansible_sudo_pass")
316 .p(config.seedServer.fabric_ip, "fabric_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800317 .p(config.seedServer.fabric_range_low, "fabric_range_low")
318 .p(config.seedServer.fabric_range_high, "fabric_range_high")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700319 .p(config.seedServer.management_ip, "management_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800320 .p(config.seedServer.management_range_low, "management_range_low")
321 .p(config.seedServer.management_range_high, "management_range_high")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700322 .p(config.seedServer.management_gw, "management_gw")
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700323 .p(config.seedServer.management_bc, "management_bc")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700324 .p(config.seedServer.management_network, "management_network")
325 .p(config.seedServer.management_iface, "management_iface")
326 .p(config.seedServer.external_ip, "external_ip")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700327 .p(config.seedServer.external_gw, "external_gw")
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700328 .p(config.seedServer.external_bc, "external_bc")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700329 .p(config.seedServer.external_network, "external_network")
330 .p(config.seedServer.external_iface, "external_iface")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700331 .p(config.seedServer.fabric_iface, "fabric_iface")
332 .p(config.seedServer.domain, "domain")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800333 .p(config.seedServer.virtualbox_support, "virtualbox_support")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700334 .p(config.seedServer.power_helper_user, "power_helper_user")
335 .p(config.seedServer.power_helper_host, "power_helper_host")
336 .p(config.seedServer.port, "ansible_ssh_port")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700337 }
338
David K. Bainbridge8b179042016-11-30 15:38:42 -0800339 if (config.passwords) {
340 extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node")
341 .p(config.passwords.maas_admin, "password_maas_admin")
342 .p(config.passwords.maas_user, "password_maas_user")
343 }
344
David K. Bainbridgef4181702016-06-17 14:44:03 -0700345 if (config.otherServers) {
346 extraVars = extraVars.p(config.otherServers.location, "prov_location")
347 .p(config.otherServers.rolesPath, "prov_role_path")
348 .p(config.otherServers.role, "prov_role")
349 }
350
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -0800351 extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
352 .p("$targetTag", "deploy_docker_tag")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700353
David K. Bainbridge8b179042016-11-30 15:38:42 -0800354 // the password set on the compute node is skipped because this is being run against the
355 // head node and we don't want to change the head node password as this node was manualy
356 // set up.
357 def skipTags = [].p(config.seedServer.skipTags).p('set_compute_node_password')
David K. Bainbridgef4181702016-06-17 14:44:03 -0700358
359 args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "prime-node.yml"
360}
361
alshabib462f6252016-08-29 16:15:28 -0700362task deployBase(type: Exec) {
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700363 executable = "ansible-playbook"
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700364 args = ["-i", config.seedServer.ip + ',']
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700365
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700366 if ( config.seedServer.user != null && config.seedServer.user != "" ) {
367 args = args << "--user=$config.seedServer.user"
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700368 }
369
David K. Bainbridge5ba01a92016-08-16 14:58:31 -0700370
371 if ( config.debug ) {
372 args = args << "-vvvv"
373 }
374
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700375 def extraVars = []
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700376 if (config.seedServer) {
377 extraVars = extraVars.p(config.seedServer.extraVars)
378 .p(config.seedServer.password, "ansible_ssh_pass")
379 .p(config.seedServer.sudoPassword, "ansible_sudo_pass")
380 .p(config.seedServer.fabric_ip, "fabric_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800381 .p(config.seedServer.fabric_range_low, "fabric_range_low")
382 .p(config.seedServer.fabric_range_high, "fabric_range_high")
383 .p(config.seedServer.management_ip, "management_ip")
384 .p(config.seedServer.management_range_low, "management_range_low")
385 .p(config.seedServer.management_range_high, "management_range_high")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700386 .p(config.seedServer.management_gw, "management_gw")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700387 .p(config.seedServer.management_network, "management_network")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800388 .p(config.seedServer.management_iface, "management_iface")
389 .p(config.seedServer.external_ip, "external_ip")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700390 .p(config.seedServer.external_gw, "external_gw")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700391 .p(config.seedServer.external_network, "external_network")
392 .p(config.seedServer.external_iface, "external_iface")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800393 .p(config.seedServer.fabric_iface, "fabric_iface")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700394 .p(config.seedServer.domain, "domain")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700395 .p(config.seedServer.virtualbox_support, "virtualbox_support")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800396 .p(config.seedServer.power_helper_user, "power_helper_user")
397 .p(config.seedServer.power_helper_host, "power_helper_host")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700398 .p(config.seedServer.port, "ansible_ssh_port")
David K. Bainbridge6ea57c12016-06-06 23:29:12 -0700399 }
400
David K. Bainbridge8b179042016-11-30 15:38:42 -0800401 if (config.passwords) {
402 extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node")
403 .p(config.passwords.maas_admin, "password_maas_admin")
404 .p(config.passwords.maas_user, "password_maas_user")
405 }
406
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700407 if (config.otherServers) {
408 extraVars = extraVars.p(config.otherServers.location, "prov_location")
409 .p(config.otherServers.rolesPath, "prov_role_path")
410 .p(config.otherServers.role, "prov_role")
411 }
412
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -0800413 extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
414 .p("$targetTag", "deploy_docker_tag")
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700415
David K. Bainbridge8b179042016-11-30 15:38:42 -0800416 // the password set on the compute node is skipped because this is being run against the
417 // head node and we don't want to change the head node password as this node was manualy
418 // set up.
419 def skipTags = [].p(config.seedServer.skipTags).p('set_compute_node_password')
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700420
421 args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "head-node.yml"
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700422}
alshabib462f6252016-08-29 16:15:28 -0700423
424prime.dependsOn {
425 updateDocker
426}
427
428tasks.addRule(new DockerFetchRule(project))
429tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
430tasks.addRule(new DockerTagRule(project))
431
432