blob: 54feb5d034e3017dac9d4a07e86b15d91a5ce0b7 [file] [log] [blame]
/*
* Copyright 2017-present Open Networking Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.yaml.snakeyaml.Yaml
ext {
// Deployment target config file (yaml format); this can be overwritten from the command line
// using the -PdeployConfig=<file-path> syntax.
deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
println "Using deployment config: $deployConfig"
File configFile = new File(deployConfig)
def yaml = new Yaml()
config = yaml.load(configFile.newReader())
// Upstream registry to simplify filling out the comps table below
upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
// Target registry to be used to publish docker images needed for deployment
targetReg = project.hasProperty('targetReg')
? project.getProperty('targetReg')
: config.docker && config.docker.registry
? config.docker.registry
: config.headnode.ip
? config.headnode.ip + ":5000"
: 'localhost:5000'
// The tag used to tag the docker images push to the target registry
targetTag = project.hasProperty('targetTag')
? project.getProperty('targetTag')
: config.docker && config.docker.imageVersion
? config.docker.imageVersion
: 'candidate'
profileName = config.common && config.common.cord_profile
? config.common.cord_profile
: 'rcord'
inventoryFileName = 'inventory/' + profileName
}
task buildImages(type: Exec) {
executable = "ansible-playbook"
args = [ "-i", inventoryFileName,
"--extra-vars", "@../genconfig/config.yml",
"--extra-vars", "build_docker_tag="+targetTag,
"--extra-vars", "cord_dir=../..",
"build-platform-install-playbook.yml" ]
}
task publish(type: Exec) {
executable = "ansible-playbook"
args = [ "-i", "../genconfig/cord-inv",
"--extra-vars", "@../genconfig/config.yml",
"--extra-vars", "build_docker_tag="+targetTag,
"--extra-vars", "deploy_docker_tag="+targetTag,
"--extra-vars", "deploy_docker_registry="+targetReg,
"publish-platform-install-playbook.yml" ]
}