blob: d198080585150b4a96992aef7807f5ddfea9819e [file] [log] [blame]
Andy Bavier175cfaf2017-03-13 18:09:21 -04001import org.yaml.snakeyaml.Yaml
2
3ext {
4
5 // Deployment target config file (yaml format); this can be overwritten from the command line
6 // using the -PdeployConfig=<file-path> syntax.
7 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
8
9 println "Using deployment config: $deployConfig"
10 File configFile = new File(deployConfig)
11 def yaml = new Yaml()
12 config = yaml.load(configFile.newReader())
13
14 // Upstream registry to simplify filling out the comps table below
15 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
16
17 // Target registry to be used to publish docker images needed for deployment
18 targetReg = project.hasProperty('targetReg')
19 ? project.getProperty('targetReg')
20 : config.docker && config.docker.registry
21 ? config.docker.registry
22 : config.headnode.ip
23 ? config.headnode.ip + ":5000"
24 : 'localhost:5000'
25
26 // The tag used to tag the docker images push to the target registry
27 targetTag = project.hasProperty('targetTag')
28 ? project.getProperty('targetTag')
29 : config.docker && config.docker.imageVersion
30 ? config.docker.imageVersion
31 : 'candidate'
32}
33
34task buildImages(type: Exec) {
35 executable = "ansible-playbook"
36 args = [
37 "--extra-vars", "@../../build/genconfig/config.yml",
38 "--extra-vars", "build_docker_tag="+targetTag,
39 "--extra-vars", "cord_dir=../..",
40 "build-xos-playbook.yml" ]
41}
42
43task publish(type: Exec) {
44 executable = "ansible-playbook"
45 args = [ "-i", "../../build/genconfig/cord-inv",
46 "--extra-vars", "@../../build/genconfig/config.yml",
47 "--extra-vars", "build_docker_tag="+targetTag,
48 "--extra-vars", "deploy_docker_tag="+targetTag,
49 "--extra-vars", "deploy_docker_registry="+targetReg,
50 "publish-xos-playbook.yml" ]
51}