2019-03-20 12:35:05 +00:00
|
|
|
OS = $(strip $(shell uname -s))
|
2021-02-23 12:24:47 +00:00
|
|
|
|
2019-03-20 12:35:05 +00:00
|
|
|
ifeq ($(OS),Darwin)
|
2021-02-23 12:24:47 +00:00
|
|
|
ARCH = darwin_amd64
|
|
|
|
PROVISIONER_MD5SUM = 42b93081b1ca548e821020949606eed7
|
|
|
|
else
|
|
|
|
ARCH = linux_amd64
|
|
|
|
PROVISIONER_MD5SUM = 34a6ce3491a5cde370e466a31f6c1f07
|
2019-03-20 12:35:05 +00:00
|
|
|
endif
|
|
|
|
|
2021-02-23 12:24:47 +00:00
|
|
|
TF_PLUGINS_DIR = $(HOME)/.terraform.d/plugins
|
2019-03-20 12:35:05 +00:00
|
|
|
|
|
|
|
PROVISIONER_NAME = terraform-provisioner-ansible
|
2021-02-23 12:24:47 +00:00
|
|
|
PROVISIONER_VERSION = v2.5.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)
|
2021-02-23 12:24:47 +00:00
|
|
|
PROVISIONER_PATH = $(TF_PLUGINS_DIR)/$(ARCH)/$(PROVISIONER_NAME)_$(PROVISIONER_VERSION)
|
2019-03-20 12:35:05 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
requirements:
|
|
|
|
ansible-galaxy install --ignore-errors --force -r ansible/requirements.yml
|
|
|
|
|
2021-02-23 12:24:47 +00:00
|
|
|
$(PROVISIONER_PATH):
|
|
|
|
@mkdir -p $(TF_PLUGINS_DIR)/$(ARCH); \
|
|
|
|
wget -q $(PROVISIONER_URL) -O $(PROVISIONER_PATH); \
|
|
|
|
chmod +x $(PROVISIONER_PATH); \
|
2019-03-20 12:35:05 +00:00
|
|
|
|
2021-02-23 12:24:47 +00:00
|
|
|
install-provisioner: $(PROVISIONER_PATH)
|
|
|
|
@echo "$(PROVISIONER_MD5SUM) $(PROVISIONER_PATH)" | md5sum -c \
|
|
|
|
|| rm -v $(PROVISIONER_PATH)
|
2019-07-29 02:35:57 +00:00
|
|
|
|
2020-09-26 14:28:34 +00:00
|
|
|
secrets:
|
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
|
|
|
|
2021-02-23 12:24:47 +00:00
|
|
|
init-terraform:
|
|
|
|
terraform init -upgrade=true
|
|
|
|
|
2019-03-20 12:35:05 +00:00
|
|
|
cleanup:
|
2021-02-23 12:24:47 +00:00
|
|
|
rm -r $(TF_PLUGINS_DIR)/$(ARCHIVE)
|
2021-01-25 20:45:35 +00:00
|
|
|
|
|
|
|
ssh-config: export SSH_CONFIG_DIR ?= $(HOME)/.ssh/config.d
|
|
|
|
ssh-config: export SSH_CONFIG_FILE ?= infra-nimbus
|
|
|
|
ssh-config: export SSH_USERNAME ?= $(USER)
|
|
|
|
ssh-config:
|
|
|
|
scripts/create-ssh-config.sh
|