85 lines
2.6 KiB
YAML
85 lines
2.6 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"
|
|
K0S_CONFIG_FILE: "{{.ROOT_DIR}}/k0s-config.yaml"
|
|
KUBECONFIG_FILE: "{{.ROOT_DIR}}/kubeconfig"
|
|
MAKEJINJA_CONFIG_FILE: "{{.ROOT_DIR}}/makejinja.toml"
|
|
SOPS_AGE_FILE: "{{.ROOT_DIR}}/age.key"
|
|
SOPS_CONFIG_FILE: "{{.ROOT_DIR}}/.sops.yaml"
|
|
|
|
includes:
|
|
ansible: .taskfiles/Ansible/Taskfile.yaml
|
|
kubernetes:
|
|
aliases: ["k8s"]
|
|
taskfile: .taskfiles/Kubernetes/Taskfile.yaml
|
|
flux: .taskfiles/Flux/Taskfile.yaml
|
|
k0s: .taskfiles/K0s/Taskfile.yaml
|
|
repo: .taskfiles/Repo/Taskfile.yaml
|
|
sops: .taskfiles/Sops/Taskfile.yaml
|
|
workstation: .taskfiles/Workstation/Taskfile.yaml
|
|
|
|
tasks:
|
|
|
|
default: task -l
|
|
|
|
init:
|
|
desc: Initialize template files and directories
|
|
cmds:
|
|
- 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
|
|
status:
|
|
- test -f {{.BOOTSTRAP_ADDONS_FILE}}
|
|
- test -f {{.BOOTSTRAP_CONFIG_FILE}}
|
|
|
|
configure:
|
|
desc: Configure repository from Ansible vars
|
|
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
|
|
cmds:
|
|
- task: .pre-validate
|
|
- task: .template
|
|
- task: .post-validate
|
|
|
|
.pre-validate:
|
|
internal: true
|
|
cmd: ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/validate.yaml
|
|
env:
|
|
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false"
|
|
preconditions:
|
|
- sh: test -f {{.BOOTSTRAP_ADDONS_FILE}}
|
|
- sh: test -f {{.BOOTSTRAP_CONFIG_FILE}}
|
|
|
|
.template:
|
|
internal: true
|
|
cmds:
|
|
- ./.venv/bin/makejinja --keep-trailing-newline --force
|
|
- task: sops:encrypt:all
|
|
preconditions:
|
|
- sh: test -f {{.BOOTSTRAP_ADDONS_FILE}}
|
|
- sh: test -f {{.BOOTSTRAP_CONFIG_FILE}}
|
|
- sh: test -f {{.BOOTSTRAP_DIR}}/scripts/loader.py
|
|
- sh: test -f {{.MAKEJINJA_CONFIG_FILE}}
|
|
|
|
.post-validate:
|
|
internal: true
|
|
cmds:
|
|
- task: kubernetes:kubeconform
|