2023-11-12 16:50:05 -08:00
|
|
|
|
|
|
|
include ../config.mk
|
|
|
|
include ../terraform/terraform.mk
|
|
|
|
|
2024-01-18 18:14:17 -08:00
|
|
|
# I don't remember why I had this at all:
|
|
|
|
#AWS_REGION = $(AWS_REGION)
|
2023-11-12 16:50:05 -08:00
|
|
|
|
|
|
|
SSH := ssh -o "StrictHostKeyChecking=no" -o UserKnownHostsFile=/dev/null -o ProxyCommand="sh -c \"aws --region $(AWS_REGION) ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p\"" -i ../terraform/privkey -l ubuntu
|
|
|
|
|
|
|
|
default: ansible
|
|
|
|
|
|
|
|
ansible: toolcheck inventory.yaml
|
|
|
|
timeout --foreground 300 bash -c -- 'until $(SSH) $(INSTANCE_ID) "/bin/true"; do sleep 0.5; done'
|
|
|
|
export ANSIBLE_NOCOWS=1; ansible-playbook -i inventory.yaml --private-key ../terraform/privkey -l social site.yaml
|
|
|
|
|
|
|
|
ssh: inventory.yaml
|
|
|
|
$(SSH) $(INSTANCE_ID)
|
|
|
|
|
|
|
|
inventory.yaml: inventory.tmpl.yaml sedline
|
|
|
|
sed $(SEDLINE) inventory.tmpl.yaml > inventory.yaml
|
|
|
|
|
|
|
|
SEDLINE =
|
|
|
|
|
2024-01-18 18:14:17 -08:00
|
|
|
sedline: terraform_sedline config_sedline s3_sedline
|
2023-11-12 16:50:05 -08:00
|
|
|
|
|
|
|
config_sedline: $(addprefix __sed_,$(shell grep '^[0-9A-Z_]' ../config.mk | awk '{print $$1}'))
|
|
|
|
|
|
|
|
terraform_sedline: $(addprefix __sed_,$(shell grep '^[0-9A-Z_]' ../terraform/terraform.mk | awk '{print $$1}'))
|
|
|
|
|
|
|
|
__sed_%:
|
|
|
|
$(eval SEDLINE := $$(SEDLINE) -e 's/{{$*}}/$($*)/')
|
|
|
|
|
2024-01-18 18:14:17 -08:00
|
|
|
# FIXME: this is awful because it's all in the clear
|
|
|
|
s3_sedline:
|
|
|
|
$(eval SEDLINE := $$(SEDLINE) -e 's/{{S3_IAM_ID}}/$(shell head -1 ../.s3_iam_credentials)/')
|
|
|
|
$(eval SEDLINE := $$(SEDLINE) -e 's/{{S3_IAM_SECRET}}/$(shell tail -1 ../.s3_iam_credentials)/')
|
2023-11-12 16:50:05 -08:00
|
|
|
|
|
|
|
# FIXME: DRY this target
|
|
|
|
|
|
|
|
CHECK_TOOLS = ansible
|
|
|
|
|
|
|
|
toolcheck:
|
|
|
|
@echo
|
|
|
|
@echo "Checking applications..."
|
|
|
|
@ FAIL=""; \
|
|
|
|
for TOOL in $(CHECK_TOOLS); do \
|
|
|
|
which $${TOOL} >/dev/null || FAIL="$${FAIL} $${TOOL}"; \
|
|
|
|
done; \
|
|
|
|
if test -n "$${FAIL}"; then \
|
|
|
|
echo "ERROR: You are missing the following:$${FAIL}"; \
|
|
|
|
echo "Please make sure all necessary tools are installed and available in your path"; \
|
|
|
|
echo; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
@echo
|
2024-01-18 18:14:17 -08:00
|
|
|
mkdir -p credentials/mastodon
|
2023-11-12 16:50:05 -08:00
|
|
|
|
|
|
|
|