terraform-incus/Makefile
Ben Vincent 25700185bc chore: update makefile, add roles
- add victoriametrics cluster roles
- change terragrunt to be 8 threads for plan
2025-07-08 20:11:19 +10:00

64 lines
2.1 KiB
Makefile

SHELL := /bin/bash
ENVIRONMENT ?= au-syd1
ENV_DIR = environments/$(ENVIRONMENT)
.PHONY: clean init plan apply venv hiera output
define vault_env
@export VAULT_ADDR="https://vault.service.consul:8200" && \
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID) && \
export PUPPET_CERT_CA=$$(vault kv get -field=public_key kv/service/puppet/certificates/ca) && \
export PUPPET_CERT_PUB=$$(vault kv get -field=public_key kv/service/puppet/certificates/terraform) && \
export PUPPET_CERT_PRIV=$$(vault kv get -field=private_key kv/service/puppet/certificates/terraform) && \
export TERRAGRUNT_EXCLUDE_DIR="templates/base" \
export $$(vault read -format=json kv/data/service/terraform/incus | jq -r '.data.data | to_entries[] | "\(.key)=\(.value)"')
endef
clean:
@echo "Cleaning Terraform files..."
@find ./ -wholename '*.terragrunt-cache*' -delete
@find ./ -name 'terragrunt_rendered.json' -delete
@echo "Cleaning Python VENV..."
@rm -rf .venv
init:
@$(call vault_env) && \
terragrunt run-all --terragrunt-non-interactive init --upgrade
plan: init
@$(call vault_env) && \
terragrunt run-all --terragrunt-parallelism 8 --terragrunt-non-interactive plan
apply:
@$(call vault_env) && \
terragrunt run-all --terragrunt-parallelism 5 --terragrunt-non-interactive apply
output:
@$(call vault_env) && \
rm -f tf_outputs.json && \
terragrunt run-all --terragrunt-parallelism 10 --terragrunt-non-interactive output -json >> tf_outputs.json
hiera:
@echo "Setting up virtual environment with uv..."
uv venv .venv && \
source .venv/bin/activate && \
uv pip install -r ci/autonode/requirements.txt
@echo "Running update_hiera"
.venv/bin/python ci/autonode/update_hiera.py \
--output-json tf_outputs.json \
--repo-url https://git.query.consul/unkinben/puppet-prod.git \
--clone-path $$(mktemp) \
--commit-template "Add Hiera config for {{ vmname }}" \
--file-template ci/autonode/templates/node.yaml.j2 \
--base-branch develop
venv:
uv venv --python 3.12 venv && \
source venv/bin/activate && \
uv pip install -r ci/requirements.txt
list:
source venv/bin/activate && \
python ci/review.py