blob: bf3d0dc0ddba07083b5ef0f3dea0ecd175c6db8c [file] [log] [blame]
Scott Baker57196542017-04-11 15:48:17 -07001import 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 profileName = config.common && config.common.cord_profile
34 ? config.common.cord_profile
35 : 'rcord'
36
37 inventoryFileName = 'inventory/' + profileName
38}
39
40task buildImages(type: Exec) {
41 executable = "ansible-playbook"
42 args = [ "-i", inventoryFileName,
43 "--extra-vars", "@../genconfig/config.yml",
44 "--extra-vars", "build_docker_tag="+targetTag,
45 "--extra-vars", "cord_dir=../..",
46 "build-platform-install-playbook.yml" ]
47}
48
49task publish(type: Exec) {
50 executable = "ansible-playbook"
51 args = [ "-i", "../genconfig/cord-inv",
52 "--extra-vars", "@../genconfig/config.yml",
53 "--extra-vars", "build_docker_tag="+targetTag,
54 "--extra-vars", "deploy_docker_tag="+targetTag,
55 "--extra-vars", "deploy_docker_registry="+targetReg,
56 "publish-platform-install-playbook.yml" ]
57}