Andy Bavier | 175cfaf | 2017-03-13 18:09:21 -0400 | [diff] [blame] | 1 | import org.yaml.snakeyaml.Yaml |
| 2 | |
| 3 | ext { |
| 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 Bavier | abda381 | 2017-05-04 16:46:07 -0700 | [diff] [blame] | 34 | // 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 Bavier | 396f7c0 | 2017-05-03 08:52:40 -0700 | [diff] [blame] | 37 | task 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 Bavier | abda381 | 2017-05-04 16:46:07 -0700 | [diff] [blame] | 46 | // Build all XOS images from source. |
Andy Bavier | 175cfaf | 2017-03-13 18:09:21 -0400 | [diff] [blame] | 47 | task 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 Bavier | abda381 | 2017-05-04 16:46:07 -0700 | [diff] [blame] | 56 | // Publish XOS images to the head node registry. |
Andy Bavier | 175cfaf | 2017-03-13 18:09:21 -0400 | [diff] [blame] | 57 | task 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 | } |