blob: 826c3b192858facfb9214e02bb9f324771b7f2ab [file] [log] [blame]
Zsolt Haraszti2a792f62016-05-12 17:49:02 -07001/*
2 * Copyright 2012 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17ext {
18
19 // Target registry to be used to publish docker images needed for deployment
20 targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
21
22 // The tag used to tag the docker images push to the target registry
23 targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
24
25}
26
David K. Bainbridgeb5415042016-05-13 17:06:10 -070027task buildBootstrapImage(type: Exec) {
28 commandLine '/usr/bin/docker', 'build', '-t', 'cord-maas-bootstrap', './bootstrap'
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070029}
30
David K. Bainbridgeb5415042016-05-13 17:06:10 -070031task tagBootstrapImage(type: Exec) {
32 dependsOn buildBootstrapImage
33 commandLine '/usr/bin/docker', 'tag', 'cord-maas-bootstrap', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070034}
35
David K. Bainbridgeb5415042016-05-13 17:06:10 -070036task publishBootstrapImage(type: Exec) {
37 dependsOn tagBootstrapImage
38 commandLine '/usr/bin/docker', 'push', "$targetReg/cord-maas-bootstrap:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070039}
40
David K. Bainbridgeb5415042016-05-13 17:06:10 -070041task buildAutomationImage(type: Exec) {
42 commandLine '/usr/bin/docker', 'build', '-t', "cord-maas-automation", "./automation"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070043}
44
David K. Bainbridgeb5415042016-05-13 17:06:10 -070045task tagAutomationImage(type: Exec) {
46 dependsOn buildAutomationImage
47 commandLine '/usr/bin/docker', 'tag', 'cord-maas-automation', "$targetReg/cord-maas-automation:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070048}
49
David K. Bainbridgeb5415042016-05-13 17:06:10 -070050task publishAutomationImage(type: Exec) {
51 dependsOn tagAutomationImage
52 commandLine '/usr/bin/docker', 'push', "$targetReg/cord-maas-automation:$targetTag"
53}
54
55task buildHarvesterImage(type: Exec) {
56 commandLine '/usr/bin/docker', 'build', '-t', "cord-maas-dhcp-harvester", "./harvester"
57}
58
59task tagHarvesterImage(type: Exec) {
60 dependsOn buildHarvesterImage
61 commandLine '/usr/bin/docker', 'tag', 'cord-maas-dhcp-harvester', "$targetReg/cord-maas-dhcp-harvester:$targetTag"
62}
63
64task publishHarvesterImage(type: Exec) {
65 dependsOn tagHarvesterImage
66 commandLine '/usr/bin/docker', 'push', "$targetReg/cord-maas-dhcp-harvester:$targetTag"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070067}
68
69// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
70
71// To be used to fetch upstream binaries, clone repos, etc.
72task fetch(type: Exec) {
73 // this is where we fetch upstream artifacts that we do not need internet for the build phase"
74 // Placeholdr example:
75 commandLine "/usr/bin/docker", "pull", "golang:alpine"
David K. Bainbridgeb5415042016-05-13 17:06:10 -070076 commandLine "/usr/bin/docker", "pull", "python:2.7-alpine"
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070077}
78
79// To be used to generate all needed binaries that need to be present on the target
80// as docker images in the local docker runner.
81task buildImages {
David K. Bainbridgeb5415042016-05-13 17:06:10 -070082 dependsOn buildBootstrapImage
83 dependsOn buildHarvesterImage
84 dependsOn buildAutomationImage
85}
86
87task tagImages {
88 dependsOn tagBootstrapImage
89 dependsOn tagHarvesterImage
90 dependsOn tagAutomationImage
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070091}
92
93task publish {
David K. Bainbridgeb5415042016-05-13 17:06:10 -070094 dependsOn publishBootstrapImage
95 dependsOn publishHarvesterImage
96 dependsOn publishAutomationImage
Zsolt Haraszti2a792f62016-05-12 17:49:02 -070097}
David K. Bainbridgeb5415042016-05-13 17:06:10 -070098
99// ~~~~~~~~~~~~~~~~~~~ Deployment / Test Tasks ~~~~~~~~~~~~~~~~~~~~~~~
100
101// This task will invoke the ansible configuration on the vagrant head node. The ansible deployment is
102// executed remotely to the head node as this is a more realistic scenario for a production deployment.
103// The assumption is that this task is executed from the maasdev virtual machine as it access the head
104// node virtual box over a private network.
105//
106// TODO: Currently the deployment of the head node does not use the locally built docker containers, it
107// should be modified to do so. This likely means that we need to configure docker on the head node
108// to access the docker registry on the maasdev virtual box.
109task deployMaas(type: Exec) {
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700110 commandLine '/usr/bin/ansible-playbook', '-i', '10.100.198.202,', '--skip-tags=switch_support,interface_config', 'dev-head-node.yml', '--extra-vars=external_iface=eth0 fabric_ip=10.1.1.1/24'
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700111}
112