Makefile 599 B

123456789101112131415161718192021222324252627282930
  1. HOSTS := bastion consul
  2. HOST_DIRS := $(addprefix files/,$(HOSTS))
  3. TARGETS := $(addsuffix /cloud-init.txt,$(HOST_DIRS))
  4. all: $(TARGETS)
  5. define make-goal
  6. $1/cloud-init.txt: $(wildcard files/common/*.sh) $(wildcard $1/*.yaml) $(wildcard $1/*.sh)
  7. endef
  8. $(foreach hdir,$(HOST_DIRS),$(eval $(call make-goal,$(hdir))))
  9. $(TARGETS):
  10. $(CURDIR)/bin/write-mime-multipart --output=$@ $^
  11. plan: $(TARGETS)
  12. terraform $@
  13. apply: $(TARGETS)
  14. terraform $@
  15. destroy:
  16. terraform plan -destroy -out=destroy.tfplan
  17. terraform apply destroy.tfplan
  18. clean:
  19. rm $(TARGETS)
  20. .PHONY: all plan apply clean destroy