| 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" ] |
| } |