2022-11-02 18:26:52 +00:00
|
|
|
VENV ?= venv
|
|
|
|
|
|
|
|
.PHONY: default
|
|
|
|
default: check
|
2022-02-16 17:56:18 +00:00
|
|
|
|
2022-11-28 06:44:55 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: cluster bootstrap-values apply
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
.PHONY: cluster
|
2022-05-18 21:22:21 +00:00
|
|
|
cluster: ansible-cluster
|
2022-02-17 22:03:42 +00:00
|
|
|
|
2022-11-02 18:26:52 +00:00
|
|
|
# Ensures virtualenv is present
|
|
|
|
$(VENV):
|
|
|
|
python3 -m venv $(VENV)
|
|
|
|
$(VENV)/bin/pip install -r requirements.txt
|
|
|
|
|
|
|
|
# Installs pre-commit hooks
|
|
|
|
.PHONY: install-hooks
|
|
|
|
install-hooks: $(VENV)
|
|
|
|
$(VENV)/bin/pre-commit install --install-hooks
|
|
|
|
|
|
|
|
# Checks files for encryption
|
|
|
|
.PHONY: check
|
|
|
|
check: $(VENV)
|
|
|
|
$(VENV)/bin/pre-commit run --all-files
|
|
|
|
|
|
|
|
# Creates a new secrets baseline
|
|
|
|
.secrets-baseline: $(VENV)
|
|
|
|
$(VENV)/bin/detect-secrets scan --exclude-secrets '(\$${.*}|from_env|fake|!secret)' > .secrets-baseline
|
|
|
|
|
|
|
|
# Audits secrets against baseline
|
|
|
|
.PHONY: secrets-audit
|
|
|
|
secrets-audit: $(VENV) .secrets-baseline
|
|
|
|
$(VENV)/bin/detect-secrets audit .secrets-baseline
|
|
|
|
|
|
|
|
# Updates secrets baseline
|
|
|
|
.PHONY: secrets-update
|
|
|
|
secrets-update: $(VENV) .secrets-baseline
|
|
|
|
$(VENV)/bin/detect-secrets scan --baseline .secrets-baseline
|
2022-02-27 22:49:00 +00:00
|
|
|
|
2022-11-02 21:20:09 +00:00
|
|
|
.PHONY: ansible_galaxy
|
|
|
|
ansible_galaxy: ansible_galaxy/ansible_collections ansible_galaxy/roles
|
|
|
|
|
|
|
|
ansible_galaxy/ansible_collections: $(VENV) ./ansible_galaxy/requirements.yml
|
2022-11-21 01:26:33 +00:00
|
|
|
$(VENV)/bin/ansible-galaxy collection install -p ./ansible_galaxy -r ./ansible_galaxy/requirements.yml
|
2022-11-02 21:20:09 +00:00
|
|
|
|
|
|
|
ansible_galaxy/roles: $(VENV) ./ansible_galaxy/requirements.yml
|
2022-11-21 01:26:33 +00:00
|
|
|
$(VENV)/bin/ansible-galaxy install -p ./ansible_galaxy/roles -r ./ansible_galaxy/requirements.yml
|
2022-07-25 22:40:22 +00:00
|
|
|
|
|
|
|
.PHONY: ansible-cluster
|
2022-11-02 21:20:09 +00:00
|
|
|
ansible-cluster: $(VENV) ansible_galaxy
|
2022-11-28 06:44:55 +00:00
|
|
|
env VIRTUAL_ENV=$(VENV) $(VENV)/bin/ansible-playbook -vv \
|
2022-05-25 03:09:16 +00:00
|
|
|
$(shell test -f vault-keys.json && echo '-e "@vault-keys.json"') \
|
2022-11-02 21:20:09 +00:00
|
|
|
./ansible_playbooks/setup-cluster.yml
|
2022-02-16 17:56:18 +00:00
|
|
|
|
2022-07-25 22:40:22 +00:00
|
|
|
.PHONY: bootstrap-values
|
2022-11-10 18:18:02 +00:00
|
|
|
bootstrap-values: $(VENV) ansible_galaxy
|
2022-11-02 18:26:52 +00:00
|
|
|
env VIRTUAL_ENV=$(VENV) $(VENV)/bin/ansible-playbook -vv \
|
|
|
|
-e "@vault-keys.json" \
|
2022-11-02 21:20:09 +00:00
|
|
|
./ansible_playbooks/bootstrap-values.yml
|
2022-07-25 22:40:22 +00:00
|
|
|
|
2023-01-07 22:09:38 +00:00
|
|
|
.PHONY: recover-consul
|
|
|
|
recover-consul: $(VENV)
|
|
|
|
$(VENV)/bin/ansible-playbook ./ansible_playbooks/recover-consul.yaml
|
|
|
|
|
|
|
|
.PHONY: recover-nomad
|
|
|
|
recover-nomad: $(VENV)
|
|
|
|
$(VENV)/bin/ansible-playbook ./ansible_playbooks/recover-nomad.yaml
|
|
|
|
|
2022-09-07 18:05:27 +00:00
|
|
|
.PHONY: unseal-vault
|
2023-01-07 22:09:38 +00:00
|
|
|
unseal-vault: $(VENV)
|
2023-02-14 20:28:19 +00:00
|
|
|
env VIRTUAL_ENV=$(VENV) $(VENV)/bin/ansible-playbook -vv \
|
2022-11-02 18:26:52 +00:00
|
|
|
-e "@vault-keys.json" \
|
2022-11-02 21:20:09 +00:00
|
|
|
./ansible_playbooks/unseal-vault.yml
|
2022-09-07 18:05:27 +00:00
|
|
|
|
2022-07-25 17:50:12 +00:00
|
|
|
.PHONY: init
|
|
|
|
init:
|
|
|
|
@terraform init
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
.PHONY: plan
|
|
|
|
plan:
|
2022-05-25 03:09:16 +00:00
|
|
|
@terraform plan \
|
|
|
|
-var "nomad_secret_id=$(shell jq -r .SecretID nomad_bootstrap.json)" \
|
|
|
|
-var "vault_token=$(shell jq -r .root_token vault-keys.json)"
|
2022-02-16 17:56:18 +00:00
|
|
|
|
|
|
|
.PHONY: apply
|
|
|
|
apply:
|
2022-05-25 03:09:16 +00:00
|
|
|
@terraform apply \
|
2022-11-28 06:44:55 +00:00
|
|
|
-auto-approve \
|
2022-05-25 03:09:16 +00:00
|
|
|
-var "nomad_secret_id=$(shell jq -r .SecretID nomad_bootstrap.json)" \
|
|
|
|
-var "vault_token=$(shell jq -r .root_token vault-keys.json)"
|
2022-11-28 06:44:55 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
env VIRTUAL_ENV=$(VENV) $(VENV)/bin/ansible-playbook -vv \
|
|
|
|
./ansible_playbooks/clear-data.yml
|
|
|
|
find -name "*.tfstate" -exec rm '{}' \;
|
|
|
|
rm -f ./vault-keys.json ./nomad_bootstrap.json
|