blob: 08f50cacb9c6e16f69cc0e64bc5faa1c66e11ce7 [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()
David K. Bainbridge151e8452016-12-19 23:05:51 -080086 def formattedDate = date.format("yyyy-MM-dd'T'HH:mm:ssZ")
David K. Bainbridgede0d9262016-09-13 20:12:06 -070087 return formattedDate
88}
89
David K. Bainbridge151e8452016-12-19 23:05:51 -080090def getCommitDate = { ->
91 def stdOut = new ByteArrayOutputStream()
92 exec {
93 commandLine "git", "log", "--pretty=format:%cd", "--date=format:%FT%T%z", "-n", "1"
94 standardOutput = stdOut
95 }
96 return stdOut.toString().trim()
97}
98
David K. Bainbridgede0d9262016-09-13 20:12:06 -070099def getCommitHash = { ->
100 def hashStdOut = new ByteArrayOutputStream()
101 exec {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800102 commandLine "git", "log", "--pretty=format:%H", "-n", "1"
David K. Bainbridgede0d9262016-09-13 20:12:06 -0700103 standardOutput = hashStdOut
104 }
105 return hashStdOut.toString().trim()
106}
107
108def getBranchName = { ->
109 def branchStdOut = new ByteArrayOutputStream()
110 exec {
111 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
112 standardOutput = branchStdOut
113 }
114 return branchStdOut.toString().trim()
115}
116
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700117task buildSwitchqImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800118 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-maas-switchq', './switchq'
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700119}
120
121task tagSwitchqImage(type: Exec) {
122 dependsOn buildSwitchqImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700123 commandLine "docker", 'tag', 'cord-maas-switchq', "$targetReg/cord-maas-switchq:$targetTag"
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700124}
125
126task publishSwitchqImage(type: Exec) {
127 dependsOn tagSwitchqImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700128 commandLine "docker", 'push', "$targetReg/cord-maas-switchq:$targetTag"
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700129}
130
131// Bootstrap Image
132
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700133task buildBootstrapImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800134 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-maas-bootstrap', './bootstrap'
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700135}
136
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700137task tagBootstrapImage(type: Exec) {
138 dependsOn buildBootstrapImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700139 commandLine "docker", 'tag', 'cord-maas-bootstrap', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700140}
141
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700142task publishBootstrapImage(type: Exec) {
143 dependsOn tagBootstrapImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700144 commandLine "docker", 'push', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700145}
146
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700147// IP Allocator Image
148
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700149task buildAllocationImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800150 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-ip-allocator', './ip-allocator'
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700151}
152
153task tagAllocationImage(type: Exec) {
David K. Bainbridgef22dc062016-05-31 15:35:39 -0700154 dependsOn buildAllocationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700155 commandLine "docker", 'tag', 'cord-ip-allocator', "$targetReg/cord-ip-allocator:$targetTag"
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700156}
157
158task publishAllocationImage(type: Exec) {
David K. Bainbridgef22dc062016-05-31 15:35:39 -0700159 dependsOn tagAllocationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700160 commandLine "docker", 'push', "$targetReg/cord-ip-allocator:$targetTag"
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700161}
162
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700163// Provisioner Image
164
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700165task buildProvisionerImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800166 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'cord-provisioner', './provisioner'
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700167}
168
169task tagProvisionerImage(type: Exec) {
170 dependsOn buildProvisionerImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700171 commandLine "docker", 'tag', 'cord-provisioner', "$targetReg/cord-provisioner:$targetTag"
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700172}
173
174task publishProvisionerImage(type: Exec) {
175 dependsOn tagProvisionerImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700176 commandLine "docker", 'push', "$targetReg/cord-provisioner:$targetTag"
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700177}
178
gunjan5e9bdd1d2016-07-13 14:59:33 -0700179// Config Generator Image
180
181task buildConfigGeneratorImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800182 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', 'config-generator', './config-generator'
gunjan5e9bdd1d2016-07-13 14:59:33 -0700183}
184
185task tagConfigGeneratorImage(type: Exec) {
186 dependsOn buildConfigGeneratorImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700187 commandLine "docker", 'tag', 'config-generator', "$targetReg/config-generator:$targetTag"
gunjan5e9bdd1d2016-07-13 14:59:33 -0700188}
189
190task publishConfigGeneratorImage(type: Exec) {
191 dependsOn tagConfigGeneratorImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700192 commandLine "docker", 'push', "$targetReg/config-generator:$targetTag"
gunjan5e9bdd1d2016-07-13 14:59:33 -0700193}
194
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700195// Automation Image
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700196
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700197task buildAutomationImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800198 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', "cord-maas-automation", "-f", "./automation/Dockerfile", "./automation"
David K. Bainbridgeefa951d2016-05-26 10:54:25 -0700199}
200
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700201task tagAutomationImage(type: Exec) {
202 dependsOn buildAutomationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700203 commandLine "docker", 'tag', 'cord-maas-automation', "$targetReg/cord-maas-automation:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700204}
205
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700206task publishAutomationImage(type: Exec) {
207 dependsOn tagAutomationImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700208 commandLine "docker", 'push', "$targetReg/cord-maas-automation:$targetTag"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700209}
210
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700211// DHCP Harvester Images
212
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700213task buildHarvesterImage(type: Exec) {
David K. Bainbridge151e8452016-12-19 23:05:51 -0800214 commandLine "docker", 'build', '--label', 'org.label-schema.build-date=' + getBuildTimestamp(), '--label', 'org.label-schema.vcs-ref=' + getCommitHash(), '--label', 'org.label-schema.vcs-ref-date=' + getCommitDate(), '--label', 'org.label-schema.version=' + getBranchName(), '-t', "cord-dhcp-harvester", "./harvester"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700215}
216
217task tagHarvesterImage(type: Exec) {
218 dependsOn buildHarvesterImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700219 commandLine "docker", 'tag', 'cord-dhcp-harvester', "$targetReg/cord-dhcp-harvester:$targetTag"
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700220}
221
222task publishHarvesterImage(type: Exec) {
223 dependsOn tagHarvesterImage
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700224 commandLine "docker", 'push', "$targetReg/cord-dhcp-harvester:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700225}
226
227// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
228
alshabib462f6252016-08-29 16:15:28 -0700229task updateDocker (type: Exec) {
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700230 commandLine 'sudo', 'utils/enable-remote-docker-registry', "$targetReg"
231}
232
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700233// To be used to fetch upstream binaries, clone repos, etc.
234task fetch(type: Exec) {
235 // this is where we fetch upstream artifacts that we do not need internet for the build phase"
236 // Placeholdr example:
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700237 dependsOn fetchUpstreamImages
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700238 commandLine "docker", "pull", "golang:alpine"
239 commandLine "docker", "pull", "python:2.7-alpine"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700240}
241
242// To be used to generate all needed binaries that need to be present on the target
243// as docker images in the local docker runner.
244task buildImages {
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700245 dependsOn buildBootstrapImage
246 dependsOn buildHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700247 dependsOn buildAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700248 dependsOn buildAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700249 dependsOn buildProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700250 dependsOn buildConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700251 dependsOn buildSwitchqImage
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700252}
253
254task tagImages {
255 dependsOn tagBootstrapImage
256 dependsOn tagHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700257 dependsOn tagAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700258 dependsOn tagAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700259 dependsOn tagProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700260 dependsOn tagConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700261 dependsOn tagSwitchqImage
Zsolt Haraszti2a792f62016-05-12 17:49:02 -0700262}
263
264task publish {
alshabib462f6252016-08-29 16:15:28 -0700265 //FIXME: This works because the upstream project primes the nodes before running this.
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700266 comps.each { name, spec -> if (spec.type == 'image') { dependsOn "publish" + name } }
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700267 dependsOn publishBootstrapImage
268 dependsOn publishHarvesterImage
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700269 dependsOn publishAutomationImage
David K. Bainbridge8bc905c2016-05-31 14:07:10 -0700270 dependsOn publishAllocationImage
David K. Bainbridgef0da8732016-06-01 16:15:37 -0700271 dependsOn publishProvisionerImage
gunjan5e9bdd1d2016-07-13 14:59:33 -0700272 dependsOn publishConfigGeneratorImage
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700273 dependsOn publishSwitchqImage
David K. Bainbridgeefa951d2016-05-26 10:54:25 -0700274}
275
David K. Bainbridge59bdb542016-07-01 11:07:45 -0700276
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700277// ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~
278
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700279List.metaClass.asParam = { prefix, sep ->
280 if (delegate.size() == 0) {
281 ""
282 }
283 String result = "--" + prefix + "="
284 String p = ""
285 delegate.each {
286 result += p + "${it}"
287 p = sep
288 }
289 result
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700290}
291
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700292List.metaClass.p = { value, name ->
293 if (value != null && value != "") {
294 delegate << name + "=" + value
295 } else {
296 delegate
297 }
298}
299
300List.metaClass.p = { spec ->
301 if (spec != null && spec != "") {
302 delegate += spec
303 } else {
304 delegate
305 }
306}
307
alshabib462f6252016-08-29 16:15:28 -0700308task prime (type: Exec) {
David K. Bainbridgef4181702016-06-17 14:44:03 -0700309 executable = "ansible-playbook"
310 args = ["-i", config.seedServer.ip + ',']
311
312 if ( config.seedServer.user != null && config.seedServer.user != "" ) {
313 args = args << "--user=$config.seedServer.user"
314 }
315
David K. Bainbridge5ba01a92016-08-16 14:58:31 -0700316 if ( config.debug ) {
317 args = args << "-vvvv"
318 }
319
David K. Bainbridgef4181702016-06-17 14:44:03 -0700320 def extraVars = []
321 if (config.seedServer) {
322 extraVars = extraVars.p(config.seedServer.extraVars)
323 .p(config.seedServer.password, "ansible_ssh_pass")
324 .p(config.seedServer.sudoPassword, "ansible_sudo_pass")
325 .p(config.seedServer.fabric_ip, "fabric_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800326 .p(config.seedServer.fabric_range_low, "fabric_range_low")
327 .p(config.seedServer.fabric_range_high, "fabric_range_high")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700328 .p(config.seedServer.management_ip, "management_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800329 .p(config.seedServer.management_range_low, "management_range_low")
330 .p(config.seedServer.management_range_high, "management_range_high")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700331 .p(config.seedServer.management_gw, "management_gw")
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700332 .p(config.seedServer.management_bc, "management_bc")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700333 .p(config.seedServer.management_network, "management_network")
334 .p(config.seedServer.management_iface, "management_iface")
335 .p(config.seedServer.external_ip, "external_ip")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700336 .p(config.seedServer.external_gw, "external_gw")
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700337 .p(config.seedServer.external_bc, "external_bc")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700338 .p(config.seedServer.external_network, "external_network")
339 .p(config.seedServer.external_iface, "external_iface")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700340 .p(config.seedServer.fabric_iface, "fabric_iface")
341 .p(config.seedServer.domain, "domain")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800342 .p(config.seedServer.virtualbox_support, "virtualbox_support")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700343 .p(config.seedServer.power_helper_user, "power_helper_user")
344 .p(config.seedServer.power_helper_host, "power_helper_host")
345 .p(config.seedServer.port, "ansible_ssh_port")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700346 }
347
David K. Bainbridge8b179042016-11-30 15:38:42 -0800348 if (config.passwords) {
349 extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node")
350 .p(config.passwords.maas_admin, "password_maas_admin")
351 .p(config.passwords.maas_user, "password_maas_user")
352 }
353
David K. Bainbridgef4181702016-06-17 14:44:03 -0700354 if (config.otherServers) {
355 extraVars = extraVars.p(config.otherServers.location, "prov_location")
356 .p(config.otherServers.rolesPath, "prov_role_path")
357 .p(config.otherServers.role, "prov_role")
358 }
359
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -0800360 extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
361 .p("$targetTag", "deploy_docker_tag")
David K. Bainbridgef4181702016-06-17 14:44:03 -0700362
David K. Bainbridge8b179042016-11-30 15:38:42 -0800363 // the password set on the compute node is skipped because this is being run against the
364 // head node and we don't want to change the head node password as this node was manualy
365 // set up.
366 def skipTags = [].p(config.seedServer.skipTags).p('set_compute_node_password')
David K. Bainbridgef4181702016-06-17 14:44:03 -0700367
368 args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "prime-node.yml"
369}
370
alshabib462f6252016-08-29 16:15:28 -0700371task deployBase(type: Exec) {
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700372 executable = "ansible-playbook"
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700373 args = ["-i", config.seedServer.ip + ',']
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700374
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700375 if ( config.seedServer.user != null && config.seedServer.user != "" ) {
376 args = args << "--user=$config.seedServer.user"
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700377 }
378
David K. Bainbridge5ba01a92016-08-16 14:58:31 -0700379
380 if ( config.debug ) {
381 args = args << "-vvvv"
382 }
383
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700384 def extraVars = []
David K. Bainbridge13c765c2016-05-26 11:24:22 -0700385 if (config.seedServer) {
386 extraVars = extraVars.p(config.seedServer.extraVars)
387 .p(config.seedServer.password, "ansible_ssh_pass")
388 .p(config.seedServer.sudoPassword, "ansible_sudo_pass")
389 .p(config.seedServer.fabric_ip, "fabric_ip")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800390 .p(config.seedServer.fabric_range_low, "fabric_range_low")
391 .p(config.seedServer.fabric_range_high, "fabric_range_high")
392 .p(config.seedServer.management_ip, "management_ip")
393 .p(config.seedServer.management_range_low, "management_range_low")
394 .p(config.seedServer.management_range_high, "management_range_high")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700395 .p(config.seedServer.management_gw, "management_gw")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700396 .p(config.seedServer.management_network, "management_network")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800397 .p(config.seedServer.management_iface, "management_iface")
398 .p(config.seedServer.external_ip, "external_ip")
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700399 .p(config.seedServer.external_gw, "external_gw")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700400 .p(config.seedServer.external_network, "external_network")
401 .p(config.seedServer.external_iface, "external_iface")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800402 .p(config.seedServer.fabric_iface, "fabric_iface")
David K. Bainbridgec82a4462016-06-14 12:39:01 -0700403 .p(config.seedServer.domain, "domain")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700404 .p(config.seedServer.virtualbox_support, "virtualbox_support")
David K. Bainbridgefad8cee2016-11-22 12:39:14 -0800405 .p(config.seedServer.power_helper_user, "power_helper_user")
406 .p(config.seedServer.power_helper_host, "power_helper_host")
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -0700407 .p(config.seedServer.port, "ansible_ssh_port")
David K. Bainbridge6ea57c12016-06-06 23:29:12 -0700408 }
409
David K. Bainbridge8b179042016-11-30 15:38:42 -0800410 if (config.passwords) {
411 extraVars = extraVars.p(config.passwords.compute_node, "password_compute_node")
412 .p(config.passwords.maas_admin, "password_maas_admin")
413 .p(config.passwords.maas_user, "password_maas_user")
414 }
415
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700416 if (config.otherServers) {
417 extraVars = extraVars.p(config.otherServers.location, "prov_location")
418 .p(config.otherServers.rolesPath, "prov_role_path")
419 .p(config.otherServers.role, "prov_role")
420 }
421
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -0800422 extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
423 .p("$targetTag", "deploy_docker_tag")
David K. Bainbridge97ee8052016-06-14 00:52:07 -0700424
David K. Bainbridge8b179042016-11-30 15:38:42 -0800425 // the password set on the compute node is skipped because this is being run against the
426 // head node and we don't want to change the head node password as this node was manualy
427 // set up.
428 def skipTags = [].p(config.seedServer.skipTags).p('set_compute_node_password')
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700429
430 args = args.p(skipTags.asParam("skip-tags", ",")).p(extraVars.asParam("extra-vars", " ")) << "head-node.yml"
David K. Bainbridge10b0c112016-05-24 13:17:23 -0700431}
alshabib462f6252016-08-29 16:15:28 -0700432
433prime.dependsOn {
434 updateDocker
435}
436
437tasks.addRule(new DockerFetchRule(project))
438tasks.addRule(new DockerPublishRule(project, project(':maas').prime))
439tasks.addRule(new DockerTagRule(project))
440
441