blob: 324c55059c94d4d972e4f6dfef247ee6b3edf24b [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
Andy Bavierabda3812017-05-04 16:46:07 -070034// Pull XOS images that exist on Docker Hub.
35// All images will get rebuilt during the buildImages step, but may at least
36// be able to use some intermediate images.
Andy Bavier396f7c02017-05-03 08:52:40 -070037task fetch(type: Exec) {
38 executable = "ansible-playbook"
39 args = [
40 "--extra-vars", "@../../build/genconfig/config.yml",
41 "--extra-vars", "build_docker_tag="+targetTag,
42 "--extra-vars", "cord_dir=../..",
43 "pull-xos-playbook.yml" ]
44}
45
Andy Bavierabda3812017-05-04 16:46:07 -070046// Build all XOS images from source.
Andy Bavier175cfaf2017-03-13 18:09:21 -040047task buildImages(type: Exec) {
48 executable = "ansible-playbook"
49 args = [
50 "--extra-vars", "@../../build/genconfig/config.yml",
51 "--extra-vars", "build_docker_tag="+targetTag,
52 "--extra-vars", "cord_dir=../..",
53 "build-xos-playbook.yml" ]
54}
55
Andy Bavierabda3812017-05-04 16:46:07 -070056// Publish XOS images to the head node registry.
Andy Bavier175cfaf2017-03-13 18:09:21 -040057task publish(type: Exec) {
58 executable = "ansible-playbook"
59 args = [ "-i", "../../build/genconfig/cord-inv",
60 "--extra-vars", "@../../build/genconfig/config.yml",
61 "--extra-vars", "build_docker_tag="+targetTag,
62 "--extra-vars", "deploy_docker_tag="+targetTag,
63 "--extra-vars", "deploy_docker_registry="+targetReg,
64 "publish-xos-playbook.yml" ]
65}