blob: 54feb5d034e3017dac9d4a07e86b15d91a5ce0b7 [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
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
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
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 */
17
18
Scott Baker57196542017-04-11 15:48:17 -070019import org.yaml.snakeyaml.Yaml
20
21ext {
22
23 // Deployment target config file (yaml format); this can be overwritten from the command line
24 // using the -PdeployConfig=<file-path> syntax.
25 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
26
27 println "Using deployment config: $deployConfig"
28 File configFile = new File(deployConfig)
29 def yaml = new Yaml()
30 config = yaml.load(configFile.newReader())
31
32 // Upstream registry to simplify filling out the comps table below
33 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
34
35 // Target registry to be used to publish docker images needed for deployment
36 targetReg = project.hasProperty('targetReg')
37 ? project.getProperty('targetReg')
38 : config.docker && config.docker.registry
39 ? config.docker.registry
40 : config.headnode.ip
41 ? config.headnode.ip + ":5000"
42 : 'localhost:5000'
43
44 // The tag used to tag the docker images push to the target registry
45 targetTag = project.hasProperty('targetTag')
46 ? project.getProperty('targetTag')
47 : config.docker && config.docker.imageVersion
48 ? config.docker.imageVersion
49 : 'candidate'
50
51 profileName = config.common && config.common.cord_profile
52 ? config.common.cord_profile
53 : 'rcord'
54
55 inventoryFileName = 'inventory/' + profileName
56}
57
58task buildImages(type: Exec) {
59 executable = "ansible-playbook"
60 args = [ "-i", inventoryFileName,
61 "--extra-vars", "@../genconfig/config.yml",
62 "--extra-vars", "build_docker_tag="+targetTag,
63 "--extra-vars", "cord_dir=../..",
64 "build-platform-install-playbook.yml" ]
65}
66
67task publish(type: Exec) {
68 executable = "ansible-playbook"
69 args = [ "-i", "../genconfig/cord-inv",
70 "--extra-vars", "@../genconfig/config.yml",
71 "--extra-vars", "build_docker_tag="+targetTag,
72 "--extra-vars", "deploy_docker_tag="+targetTag,
73 "--extra-vars", "deploy_docker_registry="+targetReg,
74 "publish-platform-install-playbook.yml" ]
75}