blob: c408ccdbdbdda86d6ee77cc12627f2e375f0b23a [file] [log] [blame]
Zack Williamsce63eb02017-02-28 10:46:22 -07001# CORD Master Makefile
2
3# Timestamp for log files
4TS := $(shell date +'%Y%m%dT%H%M%SZ')
5
6# Podconfig must be specified, so an invalid default
7PODCONFIG ?= invalid
8
9# Source path
10BUILD ?= .
11CORD ?= ..
12PI ?= $(BUILD)/platform-install
13MAAS ?= $(BUILD)/maas
Zack Williams2f56eee2017-07-17 09:59:16 -070014ONOS_APPS ?= $(CORD)/onos-apps
Zack Williamsce63eb02017-02-28 10:46:22 -070015
16# Configuration paths
17PODCONFIG_D ?= $(BUILD)/podconfig
18PODCONFIG_PATH ?= $(PODCONFIG_D)/$(PODCONFIG)
19
20SCENARIOS_D ?= $(BUILD)/scenarios
21GENCONFIG_D ?= $(BUILD)/genconfig
22
23# Milestones/logs paths
24M ?= $(BUILD)/milestones
25LOGS ?= $(BUILD)/logs
26
Zack Williams0a7ef162017-07-18 18:15:26 -070027ALL_MILESTONES ?= $(M)/prereqs-check $(M)/vagrant-up $(M)/copy-cord $(M)/cord-config $(M)/copy-config $(M)/prep-buildnode $(M)/prep-headnode $(M)/deploy-elasticstack $(M)/prep-computenode $(M)/glance-images $(M)/deploy-openstack $(M)/deploy-maas $(M)/deploy-computenode $(M)/docker-images $(M)/core-image $(M)/start-xos $(M)/onboard-profile $(M)/deploy-onos $(M)/onboard-openstack
Zack Williamsce63eb02017-02-28 10:46:22 -070028
29LOCAL_MILESTONES ?= $(M)/local-cord-config $(M)/local-docker-images $(M)/local-core-image $(M)/local-start-xos $(M)/local-onboard-profile
30
31# Configuration files
32MASTER_CONFIG ?= $(GENCONFIG_D)/config.yml
33MAKEFILE_CONFIG ?= $(GENCONFIG_D)/config.mk
34INVENTORY ?= $(GENCONFIG_D)/inventory.ini
35PROFILE_NAME_F ?= $(GENCONFIG_D)/cord_profile
36SCENARIO_NAME_F ?= $(GENCONFIG_D)/cord_scenario
37
38CONFIG_FILES = $(MASTER_CONFIG) $(MAKEFILE_CONFIG) $(INVENTORY) $(PROFILE_NAME_F) $(SCENARIO_NAME_F)
39
40include $(MAKEFILE_CONFIG)
41
42# Set using files from genconfig
43SCENARIO = $(shell cat $(SCENARIO_NAME_F))
44PROFILE = $(shell cat $(PROFILE_NAME_F))
45
46# Host names for SSH commands
47BUILDNODE ?= head1
48HEADNODE ?= ${BUILDNODE}
49
50# Vagrant config
51VAGRANT_PROVIDER ?= libvirt
52VAGRANT_VMS ?= $(HEADNODE)
53VAGRANT_CWD ?= $(SCENARIOS_D)/$(SCENARIO)/
54SSH_CONFIG ?= ~/.ssh/config # Vagrant modifies this, should it always?
55
56# Ansible args, for verbosity and other runtime parameters
57ANSIBLE_ARGS ?=
58
59# Commands
60SHELL = bash -o pipefail
61VAGRANT ?= VAGRANT_CWD=$(VAGRANT_CWD) vagrant
62ANSIBLE ?= ansible -i $(INVENTORY)
63ANSIBLE_PB ?= ansible-playbook $(ANSIBLE_ARGS) -i $(INVENTORY) --extra-vars @$(MASTER_CONFIG)
64ANSIBLE_PB_LOCAL ?= ansible-playbook $(ANSIBLE_ARGS) -i $(PI)/inventory/head-localhost --extra-vars "@/opt/cord_profile/genconfig/config.yml"
65ANSIBLE_PB_MAAS ?= ansible-playbook $(ANSIBLE_ARGS) -i /etc/maas/ansible/pod-inventory --extra-vars "@/opt/cord_profile/genconfig/config.yml"
66IMAGEBUILDER ?= python $(BUILD)/scripts/imagebuilder.py
67LOGCMD ?= 2>&1 | tee -a $(LOGS)/$(TS)_$(@F)
68SSH_HEAD ?= ssh $(HEADNODE)
69SSH_BUILD ?= ssh $(BUILDNODE)
70
71# default target, prints help
72.DEFAULT: help
73
74help:
75 @echo "Please specify a target (config, build, teardown, ...)"
76
77# Config file generation
78config: $(CONFIG_FILES)
79
Zack Williamsce63eb02017-02-28 10:46:22 -070080$(CONFIG_FILES):
81 ansible-playbook -i 'localhost,' --extra-vars="cord_podconfig='$(PODCONFIG_PATH)' genconfig_dir='$(GENCONFIG_D)' scenarios_dir='$(SCENARIOS_D)'" $(BUILD)/ansible/genconfig.yml $(LOGCMD)
82
83printconfig: config
84 @echo "Scenario: $(SCENARIO)"
85 @echo "Profile: $(PROFILE)"
86
87# Primary Targets
88# Many of these targets use target-specific variables
89# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
90
91build: $(BUILD_TARGETS)
92
93# Utility targets
94
95xos-teardown: xos-update-images
96 $(ANSIBLE_PB) $(PI)/teardown-playbook.yml $(LOGCMD)
97 rm -f $(M)/onboard-profile $(M)/local-onboard-profile
98
99xos-update-images: clean-images
Zack Williams0a7ef162017-07-18 18:15:26 -0700100 rm -f $(M)/start-xos $(M)/local-start-xos
Zack Williamsce63eb02017-02-28 10:46:22 -0700101
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700102ansible-ping:
103 $(ANSIBLE) -m ping all $(LOGCMD)
104
105ansible-setup:
106 $(ANSIBLE) -m setup all $(LOGCMD)
107
Zack Williamsa10094b2017-07-23 13:54:12 -0700108collect-diag:
109 $(ANSIBLE_PB) $(PI)/collect-diag-playbook.yml $(LOGCMD)
110
Zack Williamsce63eb02017-02-28 10:46:22 -0700111compute-node-refresh:
112 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD)
113
114vagrant-destroy:
115 $(VAGRANT) destroy $(LOGCMD)
116 rm -f $(M)/vagrant-up
117
118clean-images:
Zack Williams0a7ef162017-07-18 18:15:26 -0700119 rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image
Zack Williamsce63eb02017-02-28 10:46:22 -0700120
121clean-genconfig:
122 rm -f $(CONFIG_FILES)
123
124clean-profile:
125 rm -rf $(CONFIG_CORD_PROFILE_DIR)
126 rm -f $(M)/cord-config $(M)/copy-config
127
128clean-all: vagrant-destroy clean-profile clean-genconfig
129 rm -f $(ALL_MILESTONES)
130
131clean-local: clean-profile clean-genconfig
132 rm -f $(LOCAL_MILESTONES)
133
Andy Bavier4dc66472017-07-18 17:13:24 -0700134local-ubuntu-dev-env:
135 $(ANSIBLE_PB) $(PI)/bootstrap-dev-env.yml $(LOGCMD)
136
Zack Williamsce63eb02017-02-28 10:46:22 -0700137# == PREREQS == #
138VAGRANT_UP_PREREQS ?=
139CORD_CONFIG_PREREQS ?=
140COPY_CONFIG_PREREQS ?=
141PREP_BUILDNODE_PREREQS ?=
142PREP_HEADNODE_PREREQS ?=
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700143DOCKER_IMAGES_PREREQS ?=
Zack Williams0a7ef162017-07-18 18:15:26 -0700144START_XOS_PREREQS ?=
145DEPLOY_ONOS_PREREQS ?=
Zack Williamsce63eb02017-02-28 10:46:22 -0700146
147# == MILESTONES == #
148# empty target files are touched in the milestones dir to indicate completion
149
150$(M)/prereqs-check:
151 $(ANSIBLE_PB) $(PI)/prereqs-check-playbook.yml $(LOGCMD)
152 touch $@
153
154$(M)/vagrant-up: | $(VAGRANT_UP_PREREQS)
155 $(VAGRANT) up $(VAGRANT_VMS) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
156 @echo "Configuring SSH for VM's..."
157 $(VAGRANT) ssh-config $(VAGRANT_VMS) > $(SSH_CONFIG)
158 touch $@
159
160$(M)/copy-cord: | $(M)/vagrant-up
161 $(ANSIBLE_PB) $(PI)/copy-cord-playbook.yml $(LOGCMD)
162 touch $@
163
164$(M)/cord-config: | $(M)/vagrant-up $(CORD_CONFIG_PREREQS)
165 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
166 cp -r $(GENCONFIG_D) $(CONFIG_CORD_PROFILE_DIR)/genconfig
167 touch $@
168
169$(M)/copy-config: | $(COPY_CONFIG_PREREQS)
170 $(ANSIBLE_PB) $(PI)/copy-profile-playbook.yml $(LOGCMD)
171 touch $@
172
173$(M)/prep-buildnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_BUILDNODE_PREREQS)
174 $(ANSIBLE_PB) $(PI)/prep-buildnode-playbook.yml $(LOGCMD)
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700175 @echo Waiting 20 seconds to timeout SSH ControlPersist, and so future ansible commands gain docker group membership
176 sleep 20
Zack Williamsce63eb02017-02-28 10:46:22 -0700177 touch $@
178
179$(M)/prep-headnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_HEADNODE_PREREQS)
180 $(ANSIBLE_PB) $(PI)/prep-headnode-playbook.yml $(LOGCMD)
181 touch $@
182
Zack Williams0a7ef162017-07-18 18:15:26 -0700183$(M)/deploy-elasticstack: | $(M)/prep-headnode
Zack Williamsce63eb02017-02-28 10:46:22 -0700184 $(ANSIBLE_PB) $(PI)/deploy-elasticstack-playbook.yml $(LOGCMD)
185 touch $@
186
187$(M)/prep-computenode: | $(M)/prep-headnode
188 $(ANSIBLE_PB) $(PI)/prep-computenode-playbook.yml $(LOGCMD)
189 touch $@
190
191$(M)/glance-images: | $(M)/prep-headnode
192 $(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD)
193 touch $@
194
Zack Williams0a7ef162017-07-18 18:15:26 -0700195$(M)/deploy-openstack: | $(M)/deploy-elasticstack $(M)/prep-headnode $(M)/prep-computenode
Zack Williamsce63eb02017-02-28 10:46:22 -0700196 $(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD)
197 touch $@
198
199$(M)/deploy-maas: | $(M)/deploy-openstack
200 $(ANSIBLE_PB) $(MAAS)/head.yml $(LOGCMD)
201 touch $@
202
203$(M)/deploy-computenode: | $(M)/deploy-openstack
204 $(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
205 touch $@
206
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700207$(M)/docker-images: | $(M)/prep-buildnode $(DOCKER_IMAGES_PREREQS)
Zack Williamsce63eb02017-02-28 10:46:22 -0700208 $(SSH_BUILD) "cd /opt/cord/build; $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml " $(LOGCMD)
209 touch $@
210
211$(M)/core-image: | $(M)/docker-images $(M)/prep-headnode
212 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
213 touch $@
214
Zack Williams0a7ef162017-07-18 18:15:26 -0700215$(M)/start-xos: | $(M)/prep-headnode $(M)/core-image $(START_XOS_PREREQS)
Zack Williamsce63eb02017-02-28 10:46:22 -0700216 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/start-xos-playbook.yml" $(LOGCMD)
217 touch $@
218
Zack Williams2f56eee2017-07-17 09:59:16 -0700219$(M)/build-onos-apps: | $(M)/prep-buildnode
220 $(SSH_BUILD) "cd /opt/cord/onos-apps; make images" $(LOGCMD)
221 touch $@
222
Zack Williams0a7ef162017-07-18 18:15:26 -0700223$(M)/deploy-onos: | $(M)/prep-headnode $(M)/docker-images $(M)/build-onos-apps $(DEPLOY_ONOS_PREREQS)
Zack Williams2f56eee2017-07-17 09:59:16 -0700224 $(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700225 $(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
226 touch $@
227
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700228$(M)/onboard-profile: | $(M)/start-xos $(M)/deploy-onos
229 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD)
230 touch $@
231
232$(M)/onos-debug: | $(M)/onboard-profile
233 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onos-debug-playbook.yml" $(LOGCMD)
234 touch $@
235
Zack Williamsce63eb02017-02-28 10:46:22 -0700236$(M)/onboard-openstack: | $(M)/deploy-computenode $(M)/glance-images $(M)/deploy-onos $(M)/onboard-profile
237 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD)
238 touch $@
239
240# Testing targets
Zack Williamsa10094b2017-07-23 13:54:12 -0700241pod-test: $(M)/onboard-openstack collect-diag
Zack Williamsce63eb02017-02-28 10:46:22 -0700242 $(ANSIBLE_PB) $(PI)/pod-test-playbook.yml $(LOGCMD)
243
244# Local Targets, bring up XOS containers without a VM
245
246$(M)/local-cord-config:
247 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
248 touch $@
249
250$(M)/local-docker-images: | $(M)/local-cord-config
251 $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml $(LOGCMD)
252 touch $@
253
254$(M)/local-core-image: | $(M)/local-docker-images
255 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
256 touch $@
257
258$(M)/local-start-xos: | $(M)/local-core-image
259 $(ANSIBLE_PB) $(PI)/start-xos-playbook.yml $(LOGCMD)
260 touch $@
261
262$(M)/local-onboard-profile: | $(M)/local-start-xos
263 $(ANSIBLE_PB) $(PI)/onboard-profile-playbook.yml $(LOGCMD)
264 touch $@
265