blob: 9d8610d8cc90e2326a57f307ff6b2f284ffef5c5 [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
27ALL_MILESTONES ?= $(M)/prereqs-check $(M)/vagrant-up $(M)/copy-cord $(M)/cord-config $(M)/copy-config $(M)/prep-buildnode $(M)/prep-headnode $(M)/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
28
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
80
81$(CONFIG_FILES):
82 ansible-playbook -i 'localhost,' --extra-vars="cord_podconfig='$(PODCONFIG_PATH)' genconfig_dir='$(GENCONFIG_D)' scenarios_dir='$(SCENARIOS_D)'" $(BUILD)/ansible/genconfig.yml $(LOGCMD)
83
84printconfig: config
85 @echo "Scenario: $(SCENARIO)"
86 @echo "Profile: $(PROFILE)"
87
88# Primary Targets
89# Many of these targets use target-specific variables
90# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
91
92build: $(BUILD_TARGETS)
93
94# Utility targets
95
96xos-teardown: xos-update-images
97 $(ANSIBLE_PB) $(PI)/teardown-playbook.yml $(LOGCMD)
98 rm -f $(M)/onboard-profile $(M)/local-onboard-profile
99
100xos-update-images: clean-images
101 rm -f $(M)/core-image $(M)/start-xos $(M)/local-core-image $(M)local-start-xos
102
103compute-node-refresh:
104 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD)
105
106vagrant-destroy:
107 $(VAGRANT) destroy $(LOGCMD)
108 rm -f $(M)/vagrant-up
109
110clean-images:
111 rm -f $(M)/docker-images $(M)/local-docker-images
112
113clean-genconfig:
114 rm -f $(CONFIG_FILES)
115
116clean-profile:
117 rm -rf $(CONFIG_CORD_PROFILE_DIR)
118 rm -f $(M)/cord-config $(M)/copy-config
119
120clean-all: vagrant-destroy clean-profile clean-genconfig
121 rm -f $(ALL_MILESTONES)
122
123clean-local: clean-profile clean-genconfig
124 rm -f $(LOCAL_MILESTONES)
125
Andy Bavier4dc66472017-07-18 17:13:24 -0700126local-ubuntu-dev-env:
127 $(ANSIBLE_PB) $(PI)/bootstrap-dev-env.yml $(LOGCMD)
128
Zack Williamsce63eb02017-02-28 10:46:22 -0700129# == PREREQS == #
130VAGRANT_UP_PREREQS ?=
131CORD_CONFIG_PREREQS ?=
132COPY_CONFIG_PREREQS ?=
133PREP_BUILDNODE_PREREQS ?=
134PREP_HEADNODE_PREREQS ?=
135
136# == MILESTONES == #
137# empty target files are touched in the milestones dir to indicate completion
138
139$(M)/prereqs-check:
140 $(ANSIBLE_PB) $(PI)/prereqs-check-playbook.yml $(LOGCMD)
141 touch $@
142
143$(M)/vagrant-up: | $(VAGRANT_UP_PREREQS)
144 $(VAGRANT) up $(VAGRANT_VMS) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
145 @echo "Configuring SSH for VM's..."
146 $(VAGRANT) ssh-config $(VAGRANT_VMS) > $(SSH_CONFIG)
147 touch $@
148
149$(M)/copy-cord: | $(M)/vagrant-up
150 $(ANSIBLE_PB) $(PI)/copy-cord-playbook.yml $(LOGCMD)
151 touch $@
152
153$(M)/cord-config: | $(M)/vagrant-up $(CORD_CONFIG_PREREQS)
154 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
155 cp -r $(GENCONFIG_D) $(CONFIG_CORD_PROFILE_DIR)/genconfig
156 touch $@
157
158$(M)/copy-config: | $(COPY_CONFIG_PREREQS)
159 $(ANSIBLE_PB) $(PI)/copy-profile-playbook.yml $(LOGCMD)
160 touch $@
161
162$(M)/prep-buildnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_BUILDNODE_PREREQS)
163 $(ANSIBLE_PB) $(PI)/prep-buildnode-playbook.yml $(LOGCMD)
164 @echo Waiting 10 seconds to timeout SSH ControlPersist, and so future ansible commands gain docker group membership
165 sleep 10
166 touch $@
167
168$(M)/prep-headnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_HEADNODE_PREREQS)
169 $(ANSIBLE_PB) $(PI)/prep-headnode-playbook.yml $(LOGCMD)
170 touch $@
171
172$(M)/elasticstack: | $(M)/prep-headnode
173 $(ANSIBLE_PB) $(PI)/deploy-elasticstack-playbook.yml $(LOGCMD)
174 touch $@
175
176$(M)/prep-computenode: | $(M)/prep-headnode
177 $(ANSIBLE_PB) $(PI)/prep-computenode-playbook.yml $(LOGCMD)
178 touch $@
179
180$(M)/glance-images: | $(M)/prep-headnode
181 $(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD)
182 touch $@
183
184$(M)/deploy-openstack: | $(M)/elasticstack $(M)/prep-headnode $(M)/prep-computenode
185 $(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD)
186 touch $@
187
188$(M)/deploy-maas: | $(M)/deploy-openstack
189 $(ANSIBLE_PB) $(MAAS)/head.yml $(LOGCMD)
190 touch $@
191
192$(M)/deploy-computenode: | $(M)/deploy-openstack
193 $(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
194 touch $@
195
196$(M)/docker-images: | $(M)/prep-buildnode
197 $(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)
198 touch $@
199
200$(M)/core-image: | $(M)/docker-images $(M)/prep-headnode
201 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
202 touch $@
203
204$(M)/start-xos: | $(M)/prep-headnode $(M)/core-image
205 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/start-xos-playbook.yml" $(LOGCMD)
206 touch $@
207
208$(M)/onboard-profile: | $(M)/start-xos
209 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD)
210 touch $@
211
Zack Williams2f56eee2017-07-17 09:59:16 -0700212$(M)/build-onos-apps: | $(M)/prep-buildnode
213 $(SSH_BUILD) "cd /opt/cord/onos-apps; make images" $(LOGCMD)
214 touch $@
215
216$(M)/deploy-onos: | $(M)/start-xos $(M)/docker-images $(M)/build-onos-apps
217 $(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD)
Zack Williamsce63eb02017-02-28 10:46:22 -0700218 $(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
219 touch $@
220
221$(M)/onboard-openstack: | $(M)/deploy-computenode $(M)/glance-images $(M)/deploy-onos $(M)/onboard-profile
222 $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD)
223 touch $@
224
225# Testing targets
226pod-test: $(M)/onboard-openstack
227 $(ANSIBLE_PB) $(PI)/pod-test-playbook.yml $(LOGCMD)
228
229# Local Targets, bring up XOS containers without a VM
230
231$(M)/local-cord-config:
232 $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
233 touch $@
234
235$(M)/local-docker-images: | $(M)/local-cord-config
236 $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml $(LOGCMD)
237 touch $@
238
239$(M)/local-core-image: | $(M)/local-docker-images
240 $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
241 touch $@
242
243$(M)/local-start-xos: | $(M)/local-core-image
244 $(ANSIBLE_PB) $(PI)/start-xos-playbook.yml $(LOGCMD)
245 touch $@
246
247$(M)/local-onboard-profile: | $(M)/local-start-xos
248 $(ANSIBLE_PB) $(PI)/onboard-profile-playbook.yml $(LOGCMD)
249 touch $@
250