* feat: migrate to python for data validation Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: address PR comments Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: add unused kwargs to validate functions Signed-off-by: Devin Buhl <devin@buhl.casa> * chore: update renovate pip and ansible regex Signed-off-by: Devin Buhl <devin@buhl.casa> * feat: add bootstrap_nodes test Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: update taskfiles Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
91 lines
3.1 KiB
YAML
91 lines
3.1 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
|
version: "3"
|
|
|
|
vars:
|
|
# Directories
|
|
ANSIBLE_DIR: "{{.ROOT_DIR}}/ansible"
|
|
BOOTSTRAP_DIR: "{{.ROOT_DIR}}/bootstrap"
|
|
KUBERNETES_DIR: "{{.ROOT_DIR}}/kubernetes"
|
|
PRIVATE_DIR: "{{.ROOT_DIR}}/.private"
|
|
# Files
|
|
BOOTSTRAP_ADDONS_FILE: "{{.BOOTSTRAP_DIR}}/vars/addons.yaml"
|
|
BOOTSTRAP_CONFIG_FILE: "{{.BOOTSTRAP_DIR}}/vars/config.yaml"
|
|
KUBECONFIG_FILE: "{{.ROOT_DIR}}/kubeconfig"
|
|
MAKEJINJA_CONFIG_FILE: "{{.ROOT_DIR}}/makejinja.toml"
|
|
PIP_REQUIREMENTS_FILE: "{{.ROOT_DIR}}/requirements.txt"
|
|
SOPS_AGE_FILE: "{{.ROOT_DIR}}/age.key"
|
|
# Binaries
|
|
PYTHON_BIN: python3
|
|
|
|
includes:
|
|
ansible: .taskfiles/Ansible/Taskfile.yaml
|
|
kubernetes:
|
|
aliases: ["k8s"]
|
|
taskfile: .taskfiles/Kubernetes/Taskfile.yaml
|
|
flux: .taskfiles/Flux/Taskfile.yaml
|
|
k0s: .taskfiles/K0s/Taskfile.yaml
|
|
repository:
|
|
aliases: ["repo"]
|
|
taskfile: .taskfiles/Repository/Taskfile.yaml
|
|
talos: .taskfiles/Talos/Taskfile.yaml
|
|
sops: .taskfiles/Sops/Taskfile.yaml
|
|
workstation: .taskfiles/Workstation/Taskfile.yaml
|
|
|
|
tasks:
|
|
|
|
default: task -l
|
|
|
|
init:
|
|
desc: Initialize virtual env and configuration files
|
|
cmds:
|
|
- task: setup-virtual-env
|
|
- mkdir -p {{.PRIVATE_DIR}}
|
|
- cp -n {{.BOOTSTRAP_ADDONS_FILE | replace ".yaml" ".sample.yaml"}} {{.BOOTSTRAP_ADDONS_FILE}}
|
|
- cp -n {{.BOOTSTRAP_CONFIG_FILE | replace ".yaml" ".sample.yaml"}} {{.BOOTSTRAP_CONFIG_FILE}}
|
|
- cmd: echo === Configuration files copied ===
|
|
silent: true
|
|
- cmd: echo Proceed with updating the configuration files...
|
|
silent: true
|
|
- cmd: echo {{.BOOTSTRAP_CONFIG_FILE}}
|
|
silent: true
|
|
- cmd: echo {{.BOOTSTRAP_ADDONS_FILE}}
|
|
silent: true
|
|
|
|
configure:
|
|
desc: Configure repository from Ansible vars
|
|
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
|
|
cmds:
|
|
- task: .template
|
|
- task: .post-validate
|
|
|
|
.template:
|
|
internal: true
|
|
cmds:
|
|
- ./.venv/bin/makejinja
|
|
- task: sops:encrypt
|
|
preconditions:
|
|
- { msg: "Missing virtual environment", sh: "test -d {{.ROOT_DIR}}/.venv" }
|
|
- { msg: "Missing Makejinja config file", sh: "test -f {{.MAKEJINJA_CONFIG_FILE}}" }
|
|
- { msg: "Missing Makejinja loader file", sh: "test -f {{.BOOTSTRAP_DIR}}/scripts/loader.py" }
|
|
- { msg: "Missing bootstrap addons file", sh: "test -f {{.BOOTSTRAP_ADDONS_FILE}}" }
|
|
- { msg: "Missing bootstrap config file", sh: "test -f {{.BOOTSTRAP_CONFIG_FILE}}" }
|
|
|
|
.post-validate:
|
|
internal: true
|
|
cmds:
|
|
- task: kubernetes:kubeconform
|
|
|
|
setup-virtual-env:
|
|
desc: Set up virtual environment
|
|
cmds:
|
|
- "{{.PYTHON_BIN}} -m venv {{.ROOT_DIR}}/.venv"
|
|
- .venv/bin/python3 -m pip install --upgrade pip setuptools wheel
|
|
- .venv/bin/python3 -m pip install --upgrade --requirement "{{.PIP_REQUIREMENTS_FILE}}"
|
|
sources:
|
|
- "{{.PIP_REQUIREMENTS_FILE}}"
|
|
generates:
|
|
- "{{.ROOT_DIR}}/.venv/pyvenv.cfg"
|
|
preconditions:
|
|
- { msg: "Missing Pip requirements file", sh: "test -f {{.PIP_REQUIREMENTS_FILE}}" }
|