blob: 66a0dff008a83b587d93b1fe818a85bc2bdaa243 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Andy Bavier175cfaf2017-03-13 18:09:21 -040019import org.yaml.snakeyaml.Yaml
20
21ext {
22
23 // Deployment target config file (yaml format); this can be overwritten from the command line
24 // using the -PdeployConfig=<file-path> syntax.
25 deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
26
27 println "Using deployment config: $deployConfig"
28 File configFile = new File(deployConfig)
29 def yaml = new Yaml()
30 config = yaml.load(configFile.newReader())
31
32 // Upstream registry to simplify filling out the comps table below
33 upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
34
35 // Target registry to be used to publish docker images needed for deployment
36 targetReg = project.hasProperty('targetReg')
37 ? project.getProperty('targetReg')
38 : config.docker && config.docker.registry
39 ? config.docker.registry
40 : config.headnode.ip
41 ? config.headnode.ip + ":5000"
42 : 'localhost:5000'
43
44 // The tag used to tag the docker images push to the target registry
45 targetTag = project.hasProperty('targetTag')
46 ? project.getProperty('targetTag')
47 : config.docker && config.docker.imageVersion
48 ? config.docker.imageVersion
49 : 'candidate'
50}
51
Andy Bavierabda3812017-05-04 16:46:07 -070052// Pull XOS images that exist on Docker Hub.
53// All images will get rebuilt during the buildImages step, but may at least
54// be able to use some intermediate images.
Andy Bavier396f7c02017-05-03 08:52:40 -070055task fetch(type: Exec) {
56 executable = "ansible-playbook"
57 args = [
58 "--extra-vars", "@../../build/genconfig/config.yml",
59 "--extra-vars", "build_docker_tag="+targetTag,
60 "--extra-vars", "cord_dir=../..",
61 "pull-xos-playbook.yml" ]
62}
63
Andy Bavierabda3812017-05-04 16:46:07 -070064// Build all XOS images from source.
Andy Bavier175cfaf2017-03-13 18:09:21 -040065task buildImages(type: Exec) {
66 executable = "ansible-playbook"
67 args = [
68 "--extra-vars", "@../../build/genconfig/config.yml",
69 "--extra-vars", "build_docker_tag="+targetTag,
70 "--extra-vars", "cord_dir=../..",
71 "build-xos-playbook.yml" ]
72}
73
Andy Bavierabda3812017-05-04 16:46:07 -070074// Publish XOS images to the head node registry.
Andy Bavier175cfaf2017-03-13 18:09:21 -040075task publish(type: Exec) {
76 executable = "ansible-playbook"
77 args = [ "-i", "../../build/genconfig/cord-inv",
78 "--extra-vars", "@../../build/genconfig/config.yml",
79 "--extra-vars", "build_docker_tag="+targetTag,
80 "--extra-vars", "deploy_docker_tag="+targetTag,
81 "--extra-vars", "deploy_docker_registry="+targetReg,
82 "publish-xos-playbook.yml" ]
83}