Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 1 | # CORD Master Makefile |
| 2 | |
| 3 | # Timestamp for log files |
| 4 | TS := $(shell date +'%Y%m%dT%H%M%SZ') |
| 5 | |
| 6 | # Podconfig must be specified, so an invalid default |
| 7 | PODCONFIG ?= invalid |
| 8 | |
| 9 | # Source path |
| 10 | BUILD ?= . |
| 11 | CORD ?= .. |
| 12 | PI ?= $(BUILD)/platform-install |
| 13 | MAAS ?= $(BUILD)/maas |
Zack Williams | 2f56eee | 2017-07-17 09:59:16 -0700 | [diff] [blame] | 14 | ONOS_APPS ?= $(CORD)/onos-apps |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 15 | |
| 16 | # Configuration paths |
| 17 | PODCONFIG_D ?= $(BUILD)/podconfig |
| 18 | PODCONFIG_PATH ?= $(PODCONFIG_D)/$(PODCONFIG) |
| 19 | |
| 20 | SCENARIOS_D ?= $(BUILD)/scenarios |
| 21 | GENCONFIG_D ?= $(BUILD)/genconfig |
| 22 | |
| 23 | # Milestones/logs paths |
| 24 | M ?= $(BUILD)/milestones |
| 25 | LOGS ?= $(BUILD)/logs |
| 26 | |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 27 | ALL_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 Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 28 | |
| 29 | LOCAL_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 |
| 32 | MASTER_CONFIG ?= $(GENCONFIG_D)/config.yml |
| 33 | MAKEFILE_CONFIG ?= $(GENCONFIG_D)/config.mk |
| 34 | INVENTORY ?= $(GENCONFIG_D)/inventory.ini |
| 35 | PROFILE_NAME_F ?= $(GENCONFIG_D)/cord_profile |
| 36 | SCENARIO_NAME_F ?= $(GENCONFIG_D)/cord_scenario |
| 37 | |
| 38 | CONFIG_FILES = $(MASTER_CONFIG) $(MAKEFILE_CONFIG) $(INVENTORY) $(PROFILE_NAME_F) $(SCENARIO_NAME_F) |
| 39 | |
| 40 | include $(MAKEFILE_CONFIG) |
| 41 | |
| 42 | # Set using files from genconfig |
| 43 | SCENARIO = $(shell cat $(SCENARIO_NAME_F)) |
| 44 | PROFILE = $(shell cat $(PROFILE_NAME_F)) |
| 45 | |
| 46 | # Host names for SSH commands |
| 47 | BUILDNODE ?= head1 |
| 48 | HEADNODE ?= ${BUILDNODE} |
| 49 | |
| 50 | # Vagrant config |
| 51 | VAGRANT_PROVIDER ?= libvirt |
| 52 | VAGRANT_VMS ?= $(HEADNODE) |
| 53 | VAGRANT_CWD ?= $(SCENARIOS_D)/$(SCENARIO)/ |
| 54 | SSH_CONFIG ?= ~/.ssh/config # Vagrant modifies this, should it always? |
| 55 | |
| 56 | # Ansible args, for verbosity and other runtime parameters |
| 57 | ANSIBLE_ARGS ?= |
| 58 | |
| 59 | # Commands |
| 60 | SHELL = bash -o pipefail |
| 61 | VAGRANT ?= VAGRANT_CWD=$(VAGRANT_CWD) vagrant |
| 62 | ANSIBLE ?= ansible -i $(INVENTORY) |
| 63 | ANSIBLE_PB ?= ansible-playbook $(ANSIBLE_ARGS) -i $(INVENTORY) --extra-vars @$(MASTER_CONFIG) |
| 64 | ANSIBLE_PB_LOCAL ?= ansible-playbook $(ANSIBLE_ARGS) -i $(PI)/inventory/head-localhost --extra-vars "@/opt/cord_profile/genconfig/config.yml" |
| 65 | ANSIBLE_PB_MAAS ?= ansible-playbook $(ANSIBLE_ARGS) -i /etc/maas/ansible/pod-inventory --extra-vars "@/opt/cord_profile/genconfig/config.yml" |
| 66 | IMAGEBUILDER ?= python $(BUILD)/scripts/imagebuilder.py |
| 67 | LOGCMD ?= 2>&1 | tee -a $(LOGS)/$(TS)_$(@F) |
| 68 | SSH_HEAD ?= ssh $(HEADNODE) |
| 69 | SSH_BUILD ?= ssh $(BUILDNODE) |
| 70 | |
| 71 | # default target, prints help |
| 72 | .DEFAULT: help |
| 73 | |
| 74 | help: |
| 75 | @echo "Please specify a target (config, build, teardown, ...)" |
| 76 | |
| 77 | # Config file generation |
| 78 | config: $(CONFIG_FILES) |
| 79 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 80 | $(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 | |
| 83 | printconfig: 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 | |
| 91 | build: $(BUILD_TARGETS) |
| 92 | |
| 93 | # Utility targets |
| 94 | |
| 95 | xos-teardown: xos-update-images |
| 96 | $(ANSIBLE_PB) $(PI)/teardown-playbook.yml $(LOGCMD) |
| 97 | rm -f $(M)/onboard-profile $(M)/local-onboard-profile |
| 98 | |
| 99 | xos-update-images: clean-images |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 100 | rm -f $(M)/start-xos $(M)/local-start-xos |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 101 | |
Zack Williams | a10094b | 2017-07-23 13:54:12 -0700 | [diff] [blame^] | 102 | collect-diag: |
| 103 | $(ANSIBLE_PB) $(PI)/collect-diag-playbook.yml $(LOGCMD) |
| 104 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 105 | compute-node-refresh: |
| 106 | $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD) |
| 107 | |
| 108 | vagrant-destroy: |
| 109 | $(VAGRANT) destroy $(LOGCMD) |
| 110 | rm -f $(M)/vagrant-up |
| 111 | |
| 112 | clean-images: |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 113 | rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 114 | |
| 115 | clean-genconfig: |
| 116 | rm -f $(CONFIG_FILES) |
| 117 | |
| 118 | clean-profile: |
| 119 | rm -rf $(CONFIG_CORD_PROFILE_DIR) |
| 120 | rm -f $(M)/cord-config $(M)/copy-config |
| 121 | |
| 122 | clean-all: vagrant-destroy clean-profile clean-genconfig |
| 123 | rm -f $(ALL_MILESTONES) |
| 124 | |
| 125 | clean-local: clean-profile clean-genconfig |
| 126 | rm -f $(LOCAL_MILESTONES) |
| 127 | |
Andy Bavier | 4dc6647 | 2017-07-18 17:13:24 -0700 | [diff] [blame] | 128 | local-ubuntu-dev-env: |
| 129 | $(ANSIBLE_PB) $(PI)/bootstrap-dev-env.yml $(LOGCMD) |
| 130 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 131 | # == PREREQS == # |
| 132 | VAGRANT_UP_PREREQS ?= |
| 133 | CORD_CONFIG_PREREQS ?= |
| 134 | COPY_CONFIG_PREREQS ?= |
| 135 | PREP_BUILDNODE_PREREQS ?= |
| 136 | PREP_HEADNODE_PREREQS ?= |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 137 | START_XOS_PREREQS ?= |
| 138 | DEPLOY_ONOS_PREREQS ?= |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 139 | |
| 140 | # == MILESTONES == # |
| 141 | # empty target files are touched in the milestones dir to indicate completion |
| 142 | |
| 143 | $(M)/prereqs-check: |
| 144 | $(ANSIBLE_PB) $(PI)/prereqs-check-playbook.yml $(LOGCMD) |
| 145 | touch $@ |
| 146 | |
| 147 | $(M)/vagrant-up: | $(VAGRANT_UP_PREREQS) |
| 148 | $(VAGRANT) up $(VAGRANT_VMS) --provider $(VAGRANT_PROVIDER) $(LOGCMD) |
| 149 | @echo "Configuring SSH for VM's..." |
| 150 | $(VAGRANT) ssh-config $(VAGRANT_VMS) > $(SSH_CONFIG) |
| 151 | touch $@ |
| 152 | |
| 153 | $(M)/copy-cord: | $(M)/vagrant-up |
| 154 | $(ANSIBLE_PB) $(PI)/copy-cord-playbook.yml $(LOGCMD) |
| 155 | touch $@ |
| 156 | |
| 157 | $(M)/cord-config: | $(M)/vagrant-up $(CORD_CONFIG_PREREQS) |
| 158 | $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD) |
| 159 | cp -r $(GENCONFIG_D) $(CONFIG_CORD_PROFILE_DIR)/genconfig |
| 160 | touch $@ |
| 161 | |
| 162 | $(M)/copy-config: | $(COPY_CONFIG_PREREQS) |
| 163 | $(ANSIBLE_PB) $(PI)/copy-profile-playbook.yml $(LOGCMD) |
| 164 | touch $@ |
| 165 | |
| 166 | $(M)/prep-buildnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_BUILDNODE_PREREQS) |
| 167 | $(ANSIBLE_PB) $(PI)/prep-buildnode-playbook.yml $(LOGCMD) |
| 168 | @echo Waiting 10 seconds to timeout SSH ControlPersist, and so future ansible commands gain docker group membership |
| 169 | sleep 10 |
| 170 | touch $@ |
| 171 | |
| 172 | $(M)/prep-headnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_HEADNODE_PREREQS) |
| 173 | $(ANSIBLE_PB) $(PI)/prep-headnode-playbook.yml $(LOGCMD) |
| 174 | touch $@ |
| 175 | |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 176 | $(M)/deploy-elasticstack: | $(M)/prep-headnode |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 177 | $(ANSIBLE_PB) $(PI)/deploy-elasticstack-playbook.yml $(LOGCMD) |
| 178 | touch $@ |
| 179 | |
| 180 | $(M)/prep-computenode: | $(M)/prep-headnode |
| 181 | $(ANSIBLE_PB) $(PI)/prep-computenode-playbook.yml $(LOGCMD) |
| 182 | touch $@ |
| 183 | |
| 184 | $(M)/glance-images: | $(M)/prep-headnode |
| 185 | $(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD) |
| 186 | touch $@ |
| 187 | |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 188 | $(M)/deploy-openstack: | $(M)/deploy-elasticstack $(M)/prep-headnode $(M)/prep-computenode |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 189 | $(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD) |
| 190 | touch $@ |
| 191 | |
| 192 | $(M)/deploy-maas: | $(M)/deploy-openstack |
| 193 | $(ANSIBLE_PB) $(MAAS)/head.yml $(LOGCMD) |
| 194 | touch $@ |
| 195 | |
| 196 | $(M)/deploy-computenode: | $(M)/deploy-openstack |
| 197 | $(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD) |
| 198 | touch $@ |
| 199 | |
| 200 | $(M)/docker-images: | $(M)/prep-buildnode |
| 201 | $(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) |
| 202 | touch $@ |
| 203 | |
| 204 | $(M)/core-image: | $(M)/docker-images $(M)/prep-headnode |
| 205 | $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD) |
| 206 | touch $@ |
| 207 | |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 208 | $(M)/start-xos: | $(M)/prep-headnode $(M)/core-image $(START_XOS_PREREQS) |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 209 | $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/start-xos-playbook.yml" $(LOGCMD) |
| 210 | touch $@ |
| 211 | |
| 212 | $(M)/onboard-profile: | $(M)/start-xos |
| 213 | $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD) |
| 214 | touch $@ |
| 215 | |
Zack Williams | 2f56eee | 2017-07-17 09:59:16 -0700 | [diff] [blame] | 216 | $(M)/build-onos-apps: | $(M)/prep-buildnode |
| 217 | $(SSH_BUILD) "cd /opt/cord/onos-apps; make images" $(LOGCMD) |
| 218 | touch $@ |
| 219 | |
Zack Williams | 0a7ef16 | 2017-07-18 18:15:26 -0700 | [diff] [blame] | 220 | $(M)/deploy-onos: | $(M)/prep-headnode $(M)/docker-images $(M)/build-onos-apps $(DEPLOY_ONOS_PREREQS) |
Zack Williams | 2f56eee | 2017-07-17 09:59:16 -0700 | [diff] [blame] | 221 | $(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD) |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 222 | $(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD) |
| 223 | touch $@ |
| 224 | |
| 225 | $(M)/onboard-openstack: | $(M)/deploy-computenode $(M)/glance-images $(M)/deploy-onos $(M)/onboard-profile |
| 226 | $(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD) |
| 227 | touch $@ |
| 228 | |
| 229 | # Testing targets |
Zack Williams | a10094b | 2017-07-23 13:54:12 -0700 | [diff] [blame^] | 230 | pod-test: $(M)/onboard-openstack collect-diag |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 231 | $(ANSIBLE_PB) $(PI)/pod-test-playbook.yml $(LOGCMD) |
| 232 | |
| 233 | # Local Targets, bring up XOS containers without a VM |
| 234 | |
| 235 | $(M)/local-cord-config: |
| 236 | $(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD) |
| 237 | touch $@ |
| 238 | |
| 239 | $(M)/local-docker-images: | $(M)/local-cord-config |
| 240 | $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml $(LOGCMD) |
| 241 | touch $@ |
| 242 | |
| 243 | $(M)/local-core-image: | $(M)/local-docker-images |
| 244 | $(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD) |
| 245 | touch $@ |
| 246 | |
| 247 | $(M)/local-start-xos: | $(M)/local-core-image |
| 248 | $(ANSIBLE_PB) $(PI)/start-xos-playbook.yml $(LOGCMD) |
| 249 | touch $@ |
| 250 | |
| 251 | $(M)/local-onboard-profile: | $(M)/local-start-xos |
| 252 | $(ANSIBLE_PB) $(PI)/onboard-profile-playbook.yml $(LOGCMD) |
| 253 | touch $@ |
| 254 | |