2019-03-20 12:35:05 +00:00
|
|
|
OS = $(strip $(shell uname -s))
|
|
|
|
ARCH = linux_amd64
|
|
|
|
PLATFORM = linux
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
ARCH = darwin_amd64
|
|
|
|
PLATFORM = darwin
|
|
|
|
endif
|
|
|
|
|
|
|
|
PLUGIN_DIR = ~/.terraform.d/plugins
|
|
|
|
|
|
|
|
PROVISIONER_NAME = terraform-provisioner-ansible
|
2019-07-29 02:35:57 +00:00
|
|
|
PROVISIONER_VERSION = v2.3.0
|
2019-03-20 12:35:05 +00:00
|
|
|
PROVISIONER_ARCHIVE = $(PROVISIONER_NAME)-$(subst _,-,$(ARCH))_$(PROVISIONER_VERSION)
|
|
|
|
PROVISIONER_URL = https://github.com/radekg/terraform-provisioner-ansible/releases/download/$(PROVISIONER_VERSION)/$(PROVISIONER_ARCHIVE)
|
|
|
|
|
2020-09-07 21:25:32 +00:00
|
|
|
all: requirements install-provisioner secrets init-terraform
|
2019-07-29 02:35:57 +00:00
|
|
|
@echo "Success!"
|
2019-03-20 12:35:05 +00:00
|
|
|
|
2020-09-07 21:25:32 +00:00
|
|
|
plugins: install-provisioner
|
2019-03-20 12:35:05 +00:00
|
|
|
|
|
|
|
requirements:
|
|
|
|
ansible-galaxy install --ignore-errors --force -r ansible/requirements.yml
|
|
|
|
|
|
|
|
install-provisioner:
|
|
|
|
if [ ! -e $(PLUGIN_DIR)/$(ARCH)/$(PROVISIONER_NAME)_$(PROVISIONER_VERSION) ]; then \
|
|
|
|
mkdir -p $(PLUGIN_DIR); \
|
|
|
|
wget $(PROVISIONER_URL) -O $(PLUGIN_DIR)/$(ARCH)/$(PROVISIONER_NAME)_$(PROVISIONER_VERSION); \
|
|
|
|
chmod +x $(PLUGIN_DIR)/$(ARCH)/$(PROVISIONER_NAME)_$(PROVISIONER_VERSION); \
|
|
|
|
fi
|
|
|
|
|
2019-07-29 02:35:57 +00:00
|
|
|
init-terraform:
|
|
|
|
terraform init -upgrade=true
|
|
|
|
|
2020-09-26 14:28:34 +00:00
|
|
|
secrets:
|
2020-05-25 16:49:07 +00:00
|
|
|
@echo "Saving Consul certificates: ansible/files/consul*"
|
2019-03-20 12:35:05 +00:00
|
|
|
pass services/consul/ca-crt > ansible/files/consul-ca.crt
|
|
|
|
pass services/consul/ca-key > ansible/files/consul-ca.key
|
|
|
|
pass services/consul/client-crt > ansible/files/consul-client.crt
|
|
|
|
pass services/consul/client-key > ansible/files/consul-client.key
|
2020-05-25 16:49:07 +00:00
|
|
|
|
|
|
|
|
2019-03-20 12:35:05 +00:00
|
|
|
cleanup:
|
|
|
|
rm -r $(PLUGIN_DIR)/$(ARCHIVE)
|