blob: 2695f39be6206ab60f554c55cfef5b21739b7754 [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
Andy Bavier35d238e2017-07-24 16:47:22 -070027PREP_MS ?= $(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
28MAAS_MS ?= $(M)/build-maas-images $(M)/maas-prime $(M)/publish-maas-images $(M)/deploy-maas
29OPENSTACK_MS ?= $(M)/glance-images $(M)/deploy-openstack $(M)/deploy-computenode $(M)/onboard-openstack
30XOS_MS ?= $(M)/docker-images $(M)/core-image $(M)/publish-docker-images $(M)/start-xos $(M)/onboard-profile
31ONOS_MS ?= $(M)/build-onos-apps $(M)/publish-onos-apps $(M)/deploy-onos $(M)/deploy-mavenrepo
32POST_INSTALL_MS ?= $(M)/setup-automation $(M)/setup-ciab-pcu $(M)/vagrant-up-switches $(M)/compute1-up $(M)/compute2-up $(M)/compute3-up
33ALL_MILESTONES ?= $(PREP_MS) $(MAAS_MS) $(OPENSTACK_MS) $(XOS_MS) $(ONOS_MS) $(POST_INSTALL_MS)
Zack Williamsce63eb02017-02-28 10:46:22 -070034
35LOCAL_MILESTONES ?= $(M)/local-cord-config $(M)/local-docker-images $(M)/local-core-image $(M)/local-start-xos $(M)/local-onboard-profile
36
37# Configuration files
38MASTER_CONFIG ?= $(GENCONFIG_D)/config.yml
39MAKEFILE_CONFIG ?= $(GENCONFIG_D)/config.mk
40INVENTORY ?= $(GENCONFIG_D)/inventory.ini
41PROFILE_NAME_F ?= $(GENCONFIG_D)/cord_profile
42SCENARIO_NAME_F ?= $(GENCONFIG_D)/cord_scenario
43
44CONFIG_FILES = $(MASTER_CONFIG) $(MAKEFILE_CONFIG) $(INVENTORY) $(PROFILE_NAME_F) $(SCENARIO_NAME_F)
45
46include $(MAKEFILE_CONFIG)
47
48# Set using files from genconfig
49SCENARIO = $(shell cat $(SCENARIO_NAME_F))
50PROFILE = $(shell cat $(PROFILE_NAME_F))
51
52# Host names for SSH commands
53BUILDNODE ?= head1
54HEADNODE ?= ${BUILDNODE}
55
56# Vagrant config
57VAGRANT_PROVIDER ?= libvirt
58VAGRANT_VMS ?= $(HEADNODE)
Andy Bavier35d238e2017-07-24 16:47:22 -070059VAGRANT_SWITCHES ?= leaf1
Zack Williamsce63eb02017-02-28 10:46:22 -070060VAGRANT_CWD ?= $(SCENARIOS_D)/$(SCENARIO)/
61SSH_CONFIG ?= ~/.ssh/config # Vagrant modifies this, should it always?
62
63# Ansible args, for verbosity and other runtime parameters
64ANSIBLE_ARGS ?=
65
66# Commands
67SHELL = bash -o pipefail
68VAGRANT ?= VAGRANT_CWD=$(VAGRANT_CWD) vagrant
69ANSIBLE ?= ansible -i $(INVENTORY)
70ANSIBLE_PB ?= ansible-playbook $(ANSIBLE_ARGS) -i $(INVENTORY) --extra-vars @$(MASTER_CONFIG)
71ANSIBLE_PB_LOCAL ?= ansible-playbook $(ANSIBLE_ARGS) -i $(PI)/inventory/head-localhost --extra-vars "@/opt/cord_profile/genconfig/config.yml"
72ANSIBLE_PB_MAAS ?= ansible-playbook $(ANSIBLE_ARGS) -i /etc/maas/ansible/pod-inventory --extra-vars "@/opt/cord_profile/genconfig/config.yml"
73IMAGEBUILDER ?= python $(BUILD)/scripts/imagebuilder.py
74LOGCMD ?= 2>&1 | tee -a $(LOGS)/$(TS)_$(@F)
75SSH_HEAD ?= ssh $(HEADNODE)
76SSH_BUILD ?= ssh $(BUILDNODE)
77
78# default target, prints help
79.DEFAULT: help
80
81help:
82 @echo "Please specify a target (config, build, teardown, ...)"
83
84# Config file generation
85config: $(CONFIG_FILES)
86
Zack Williamsce63eb02017-02-28 10:46:22 -070087$(CONFIG_FILES):
88 ansible-playbook -i 'localhost,' --extra-vars="cord_podconfig='$(PODCONFIG_PATH)' genconfig_dir='$(GENCONFIG_D)' scenarios_dir='$(SCENARIOS_D)'" $(BUILD)/ansible/genconfig.yml $(LOGCMD)
89
90printconfig: config
91 @echo "Scenario: $(SCENARIO)"
92 @echo "Profile: $(PROFILE)"
93
94# Primary Targets
95# Many of these targets use target-specific variables
96# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
97
98build: $(BUILD_TARGETS)
99
100# Utility targets
101
102xos-teardown: xos-update-images
103 $(ANSIBLE_PB) $(PI)/teardown-playbook.yml $(LOGCMD)
104 rm -f $(M)/onboard-profile $(M)/local-onboard-profile
105
106xos-update-images: clean-images
Zack Williams0a7ef162017-07-18 18:15:26 -0700107 rm -f $(M)/start-xos $(M)/local-start-xos
Zack Williamsce63eb02017-02-28 10:46:22 -0700108
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700109ansible-ping:
110 $(ANSIBLE) -m ping all $(LOGCMD)
111
112ansible-setup:
113 $(ANSIBLE) -m setup all $(LOGCMD)
114
Zack Williamsa10094b2017-07-23 13:54:12 -0700115collect-diag:
116 $(ANSIBLE_PB) $(PI)/collect-diag-playbook.yml $(LOGCMD)
117
Zack Williamsce63eb02017-02-28 10:46:22 -0700118compute-node-refresh:
119 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD)
120
121vagrant-destroy:
122 $(VAGRANT) destroy $(LOGCMD)
123 rm -f $(M)/vagrant-up
124
125clean-images:
Andy Bavier35d238e2017-07-24 16:47:22 -0700126 rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image $(M)/build-maas-images $(M)/build-onos-apps
Zack Williamsce63eb02017-02-28 10:46:22 -0700127
128clean-genconfig:
129 rm -f $(CONFIG_FILES)
130
131clean-profile:
132 rm -rf $(CONFIG_CORD_PROFILE_DIR)
133 rm -f $(M)/cord-config $(M)/copy-config
134
135clean-all: vagrant-destroy clean-profile clean-genconfig
136 rm -f $(ALL_MILESTONES)
137
138clean-local: clean-profile clean-genconfig
139 rm -f $(LOCAL_MILESTONES)
140
Andy Bavier4dc66472017-07-18 17:13:24 -0700141local-ubuntu-dev-env:
142 $(ANSIBLE_PB) $(PI)/bootstrap-dev-env.yml $(LOGCMD)
143
Andy Bavier35d238e2017-07-24 16:47:22 -0700144
Zack Williamsce63eb02017-02-28 10:46:22 -0700145# == PREREQS == #
146VAGRANT_UP_PREREQS ?=
147CORD_CONFIG_PREREQS ?=
148COPY_CONFIG_PREREQS ?=
149PREP_BUILDNODE_PREREQS ?=
150PREP_HEADNODE_PREREQS ?=
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700151DOCKER_IMAGES_PREREQS ?=
Zack Williams0a7ef162017-07-18 18:15:26 -0700152START_XOS_PREREQS ?=
153DEPLOY_ONOS_PREREQS ?=
Andy Bavier35d238e2017-07-24 16:47:22 -0700154DEPLOY_OPENSTACK_PREREQS ?=
155SETUP_AUTOMATION_PREREQS ?=
Zack Williamsce63eb02017-02-28 10:46:22 -0700156
157# == MILESTONES == #
158# empty target files are touched in the milestones dir to indicate completion
159
Andy Bavier35d238e2017-07-24 16:47:22 -0700160# Prep targets
Zack Williamsce63eb02017-02-28 10:46:22 -0700161$(M)/prereqs-check:
162 $(ANSIBLE_PB) $(PI)/prereqs-check-playbook.yml $(LOGCMD)
163 touch $@
164
165$(M)/vagrant-up: | $(VAGRANT_UP_PREREQS)
166 $(VAGRANT) up $(VAGRANT_VMS) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
167 @echo "Configuring SSH for VM's..."
168 $(VAGRANT) ssh-config $(VAGRANT_VMS) > $(SSH_CONFIG)
169 touch $@
170
171$(M)/copy-cord: | $(M)/vagrant-up
172 $(ANSIBLE_PB) $(PI)/copy-cord-playbook.yml $(LOGCMD)
173 touch $@
174
175$(M)/cord-config: | $(M)/vagrant-up $(CORD_CONFIG_PREREQS)
176 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
177 cp -r $(GENCONFIG_D) $(CONFIG_CORD_PROFILE_DIR)/genconfig
178 touch $@
179
180$(M)/copy-config: | $(COPY_CONFIG_PREREQS)
181 $(ANSIBLE_PB) $(PI)/copy-profile-playbook.yml $(LOGCMD)
182 touch $@
183
184$(M)/prep-buildnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_BUILDNODE_PREREQS)
185 $(ANSIBLE_PB) $(PI)/prep-buildnode-playbook.yml $(LOGCMD)
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700186 @echo Waiting 20 seconds to timeout SSH ControlPersist, and so future ansible commands gain docker group membership
187 sleep 20
Zack Williamsce63eb02017-02-28 10:46:22 -0700188 touch $@
189
190$(M)/prep-headnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_HEADNODE_PREREQS)
191 $(ANSIBLE_PB) $(PI)/prep-headnode-playbook.yml $(LOGCMD)
192 touch $@
193
Zack Williams0a7ef162017-07-18 18:15:26 -0700194$(M)/deploy-elasticstack: | $(M)/prep-headnode
Zack Williamsce63eb02017-02-28 10:46:22 -0700195 $(ANSIBLE_PB) $(PI)/deploy-elasticstack-playbook.yml $(LOGCMD)
196 touch $@
197
198$(M)/prep-computenode: | $(M)/prep-headnode
199 $(ANSIBLE_PB) $(PI)/prep-computenode-playbook.yml $(LOGCMD)
200 touch $@
201
Andy Bavier35d238e2017-07-24 16:47:22 -0700202
203# MaaS targets
204$(M)/build-maas-images: | $(M)/prep-buildnode $(BUILD_MAAS_IMAGES_PREREQS)
205 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build/maas; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) build" $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700206 touch $@
207
Andy Bavier35d238e2017-07-24 16:47:22 -0700208$(M)/maas-prime: | $(M)/deploy-elasticstack
209 $(ANSIBLE_PB) $(MAAS)/prime-node.yml $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700210 touch $@
211
Andy Bavier35d238e2017-07-24 16:47:22 -0700212$(M)/publish-maas-images: | $(M)/maas-prime $(M)/build-maas-images
213 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build/maas; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) publish" $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700214 touch $@
215
Andy Bavier35d238e2017-07-24 16:47:22 -0700216$(M)/deploy-maas: | $(M)/publish-maas-images $(M)/cord-config $(M)/copy-config
217 $(ANSIBLE_PB) $(MAAS)/head-node.yml $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700218 touch $@
219
Andy Bavier35d238e2017-07-24 16:47:22 -0700220
221# ONOS targets
222$(M)/build-onos-apps: | $(M)/prep-buildnode $(BUILD_ONOS_APPS_PREREQS)
223 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/onos-apps; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) build" $(LOGCMD)
224 touch $@
225
226$(M)/publish-onos-apps: | $(M)/maas-prime $(M)/build-onos-apps
227 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/onos-apps; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) publish" $(LOGCMD)
228 touch $@
229
230$(M)/deploy-mavenrepo: | $(M)/publish-onos-apps
231 $(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD)
232 touch $@
233
234$(M)/deploy-onos: | $(M)/docker-images $(DEPLOY_ONOS_PREREQS)
235 $(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
236 touch $@
237
238
239# XOS targets
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700240$(M)/docker-images: | $(M)/prep-buildnode $(DOCKER_IMAGES_PREREQS)
Andy Bavier35d238e2017-07-24 16:47:22 -0700241 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build; $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml " $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700242 touch $@
243
Andy Bavier35d238e2017-07-24 16:47:22 -0700244$(M)/core-image: | $(M)/docker-images
Zack Williamsce63eb02017-02-28 10:46:22 -0700245 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
246 touch $@
247
Andy Bavier35d238e2017-07-24 16:47:22 -0700248# Requires ib_actions.yml file which is on the build host
249$(M)/publish-docker-images: | $(M)/maas-prime $(M)/docker-images $(M)/core-image
250 $(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build; $(ANSIBLE_PB_LOCAL) $(PI)/publish-images-playbook.yml" $(LOGCMD)
251 touch $@
252
Zack Williams0a7ef162017-07-18 18:15:26 -0700253$(M)/start-xos: | $(M)/prep-headnode $(M)/core-image $(START_XOS_PREREQS)
Zack Williamsce63eb02017-02-28 10:46:22 -0700254 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/start-xos-playbook.yml" $(LOGCMD)
255 touch $@
256
Andy Bavier35d238e2017-07-24 16:47:22 -0700257$(M)/onboard-profile: | $(M)/start-xos
258 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD)
Zack Williams2f56eee2017-07-17 09:59:16 -0700259 touch $@
260
Andy Bavier35d238e2017-07-24 16:47:22 -0700261
262# OpenStack targets
263$(M)/glance-images: | $(M)/prep-headnode
264 $(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD)
265 touch $@
266
267$(M)/deploy-openstack: | $(M)/deploy-elasticstack $(M)/prep-headnode $(M)/prep-computenode $(DEPLOY_OPENSTACK_PREREQS)
268 $(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD)
269 touch $@
270
271$(M)/deploy-computenode: | $(M)/deploy-openstack
272 $(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700273 touch $@
274
Zack Williamsa5fcefd2017-07-27 22:06:33 -0700275$(M)/onboard-profile: | $(M)/start-xos $(M)/deploy-onos
276 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD)
277 touch $@
278
279$(M)/onos-debug: | $(M)/onboard-profile
280 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onos-debug-playbook.yml" $(LOGCMD)
281 touch $@
282
Zack Williamsce63eb02017-02-28 10:46:22 -0700283$(M)/onboard-openstack: | $(M)/deploy-computenode $(M)/glance-images $(M)/deploy-onos $(M)/onboard-profile
284 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD)
285 touch $@
286
Andy Bavier35d238e2017-07-24 16:47:22 -0700287
288# Post-onboarding targets
289$(M)/setup-automation: | $(M)/onboard-profile $(M)/deploy-onos $(SETUP_AUTOMATION_PREREQS)
290 $(ANSIBLE_PB) $(PI)/cord-automation-playbook.yml $(LOGCMD)
291 touch $@
292
293
294# Additional CiaB targets
295$(M)/vagrant-up-switches: | $(M)/setup-automation
296 $(VAGRANT) up $(VAGRANT_SWITCHES) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
297 touch $@
298
299$(M)/setup-ciab-pcu: | $(M)/setup-automation
300 $(ANSIBLE_PB) $(MAAS)/setup-ciab-pcu.yml
301 touch $@
302
303$(M)/compute%-up: | $(M)/setup-ciab-pcu $(M)/vagrant-up-switches
304 $(VAGRANT) up compute$* --provider $(VAGRANT_PROVIDER) $(LOGCMD)
305 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) ansible/maas-provision.yml --extra-vars='maas_user=maas vagrant_name=cord_compute$*'" $(LOGCMD)
306 touch $@
307
308
Zack Williamsce63eb02017-02-28 10:46:22 -0700309# Testing targets
Andy Bavier35d238e2017-07-24 16:47:22 -0700310pod-test: $(M)/setup-automation collect-diag
311 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/pod-test-playbook.yml" $(LOGCMD)
312
Zack Williamsce63eb02017-02-28 10:46:22 -0700313
314# Local Targets, bring up XOS containers without a VM
Zack Williamsce63eb02017-02-28 10:46:22 -0700315$(M)/local-cord-config:
316 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
317 touch $@
318
319$(M)/local-docker-images: | $(M)/local-cord-config
320 $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml $(LOGCMD)
321 touch $@
322
323$(M)/local-core-image: | $(M)/local-docker-images
324 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
325 touch $@
326
327$(M)/local-start-xos: | $(M)/local-core-image
328 $(ANSIBLE_PB) $(PI)/start-xos-playbook.yml $(LOGCMD)
329 touch $@
330
331$(M)/local-onboard-profile: | $(M)/local-start-xos
332 $(ANSIBLE_PB) $(PI)/onboard-profile-playbook.yml $(LOGCMD)
333 touch $@
334