blob: bc05a8094b6653215f43c55a97a5033ba66407ea [file] [log] [blame]
David K. Bainbridge0a7cdbb2017-07-14 11:36:13 -07001SUBDIRS := automation config-generator harvester ip-allocator provisioner switchq
2TARGETS := build publish clean test
3PUBLIC_IMAGES := consul@sha256:0dc990ff3c44d5b5395475bcc5ebdae4fc8b67f69e17942a8b9793b3df74d290
4I2 := consul:latest
5I3 := consul
6
7ANSIBLE_ARGS?=
8MAKE_CONFIG?=config.mk
9
10# [EXPERIMENTAL] Deployment via make is currently experimental
11DEPLOY_INVENTORY=deploy-inv
12DEPLOY_CONFIG=deploy-vars
13
14# expands to lists of of the form:
15# <target>_TARGETS := <subdir1>_<target> <subdir2>_<target>
16$(foreach TARGET, $(TARGETS), $(eval $(TARGET)_TARGETS := $(addsuffix _$(TARGET), $(SUBDIRS))))
17
18ifeq ($(realpath $(MAKE_CONFIG)),)
19$(info Makefile configuration not found, defaults will be used.)
20else
21$(info Using makefile configuration "$(MAKE_CONFIG)")
22endif
23
24define recursive_rule
25$1_$2:
26 $$(MAKE) MAKE_CONFIG=$(realpath $(MAKE_CONFIG)) CONFIG=$(realpath $(CONFIG)) -C $1 $2
27endef
28
29$(foreach SUBDIR, $(SUBDIRS), $(foreach TARGET, $(TARGETS), $(eval $(call recursive_rule,$(SUBDIR),$(TARGET)))))
30
31$(foreach TARGET, $(TARGETS), $(eval $(TARGET): $($(TARGET)_TARGETS)))
32
33include help.mk
34
35ifneq ($(realpath $(MAKE_CONFIG)),)
36include $(MAKE_CONFIG)
37endif
38
39define public_image_rules
40$2.image:
41 docker pull $1
42 @touch $$@
43
44$2.publish: $2.image
45 docker tag $1 $(DOCKER_REGISTRY)/$2:$(DEPLOY_DOCKER_TAG)
46 docker push $(DOCKER_REGISTRY)/$2:$(DEPLOY_DOCKER_TAG)
47 @touch $$@
48
49publish: $2.publish
50endef
51
52$(foreach PUBLIC_IMAGE, $(PUBLIC_IMAGES), $(eval $(call public_image_rules,$(PUBLIC_IMAGE),$(word 1,$(subst @, ,$(subst :, ,$(PUBLIC_IMAGE)))))))
53
54prime:
55 ansible-playbook -i $(DEPLOY_INVENTORY) --extra-vars=@$(DEPLOY_CONFIG) $(ANSIBLE_ARGS) prime-node.yml
56
57deploy: publish
58 ansible-playbook -i $(DEPLOY_INVENTORY) --extra-vars=@$(DEPLOY_CONFIG) $(ANSIBLE_ARGS) head-node.yml
59
60config:
61 @echo "hello"
62
63clean: