eletrotupi / tcc/ Makefile6bdc28a3adcc45cf37288df8777dfa536ce0f07a
1.8 KB | 45 lines Raw
1
# Deployment helpers
2
#
3
# Day-to-day app deploys happen in GitHub Actions
4
# (.github/workflows/deploy.yml) These targets are for the host-config work,
5
# which is done rarely
6

7
SHELL := bash
8
ANSIBLE_DIR := ansible
9
INVENTORY := inventory/hosts.yml
10

11
# Only pass the vault password when it exists, so these targets keep working
12
# before the vault has been imported (scripts/import-vault.sh creates it)
13
VAULT_ARGS := $(shell [ -f $(ANSIBLE_DIR)/.vault_pass ] && echo --vault-password-file $(CURDIR)/$(ANSIBLE_DIR)/.vault_pass)
14

15
.PHONY: help deploy-diff deploy-check provision cert deploy-nginx app vault-import
16

17
help:
18
	@echo "make deploy-diff    # pull live configs and diff them against the repo"
19
	@echo "make deploy-check   # ansible --check --diff (dry run, no changes)"
20
	@echo "make provision      # full host bootstrap (setup + deploy + cert + app)"
21
	@echo "make deploy-nginx   # publish the nginx vhost (deploy.yml)"
22
	@echo "make app            # render the app config from the vault (app.yml)"
23
	@echo "make cert           # install uacme / manage certificates (cert.yml)"
24
	@echo "make vault-import   # build the encrypted vault from the live env files"
25

26
deploy-diff:
27
	$(ANSIBLE_DIR)/scripts/pull-live-configs.sh
28

29
vault-import:
30
	$(ANSIBLE_DIR)/scripts/import-vault.sh
31

32
deploy-check:
33
	cd $(ANSIBLE_DIR) && ansible-playbook -i $(INVENTORY) $(VAULT_ARGS) provision.yml --check --diff
34

35
provision:
36
	cd $(ANSIBLE_DIR) && ansible-playbook -i $(INVENTORY) $(VAULT_ARGS) provision.yml --ask-become-pass
37

38
cert:
39
	cd $(ANSIBLE_DIR) && ansible-playbook -i $(INVENTORY) $(VAULT_ARGS) cert.yml --ask-become-pass
40

41
deploy-nginx:
42
	cd $(ANSIBLE_DIR) && ansible-playbook -i $(INVENTORY) $(VAULT_ARGS) deploy.yml --ask-become-pass
43

44
app:
45
	cd $(ANSIBLE_DIR) && ansible-playbook -i $(INVENTORY) $(VAULT_ARGS) app.yml --ask-become-pass