diff --git a/.envrc b/.envrc index 48f62a73..79a2f703 100644 --- a/.envrc +++ b/.envrc @@ -9,3 +9,6 @@ export PYTHONDONTWRITEBYTECODE="1" export TALOSCONFIG="$(expand_path ./kubernetes/bootstrap/talos/clusterconfig/talosconfig)" # Bin PATH_add "$(expand_path ./.bin)" +# Taskfile +export TASK_X_ENV_PRECEDENCE=1 +export TASK_X_MAP_VARIABLES=0 diff --git a/.taskfiles/Flux/Taskfile.yaml b/.taskfiles/Flux/Taskfile.yaml index d5b59534..7aa594e5 100644 --- a/.taskfiles/Flux/Taskfile.yaml +++ b/.taskfiles/Flux/Taskfile.yaml @@ -1,75 +1,48 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' vars: - CLUSTER_SECRET_SOPS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml" - CLUSTER_SETTINGS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml" - GITHUB_DEPLOY_KEY_FILE: "{{.KUBERNETES_DIR}}/bootstrap/flux/github-deploy-key.sops.yaml" + CLUSTER_SECRET_SOPS_FILE: '{{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml' + CLUSTER_SETTINGS_FILE: '{{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml' + GITHUB_DEPLOY_KEY_FILE: '{{.KUBERNETES_DIR}}/bootstrap/flux/github-deploy-key.sops.yaml' tasks: bootstrap: desc: Bootstrap Flux into a Kubernetes cluster cmds: - - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/bootstrap/flux + - kubectl apply --server-side --kustomize {{.KUBERNETES_DIR}}/bootstrap/flux - | - if ! kubectl --kubeconfig {{.KUBECONFIG_FILE}} -n flux-system get secret sops-age >/dev/null 2>&1; then - cat {{.AGE_FILE}} | kubectl --kubeconfig {{.KUBECONFIG_FILE}} -n flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin + if ! kubectl --namespace flux-system get secret sops-age >/dev/null 2>&1; then + cat {{.SOPS_AGE_KEY_FILE}} | kubectl --namespace flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin else echo "sops-age secret already exists, skipping creation." fi - - sops --decrypt {{.CLUSTER_SECRET_SOPS_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - - - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_FILE}} - - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config + - sops --decrypt {{.CLUSTER_SECRET_SOPS_FILE}} | kubectl apply --server-side --filename - + - kubectl apply --server-side --filename {{.CLUSTER_SETTINGS_FILE}} + - kubectl apply --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config preconditions: - msg: Missing kubeconfig - sh: test -f {{.KUBECONFIG_FILE}} + sh: test -f {{.KUBECONFIG}} - msg: Missing Sops Age key file - sh: test -f {{.AGE_FILE}} - - apply: - desc: Apply a Flux Kustomization resource for a cluster - summary: | - Args: - path: Path under apps containing the Flux Kustomization resource (ks.yaml) (required) - ns: Namespace the Flux Kustomization exists in (default: flux-system) - cmd: | - flux --kubeconfig {{.KUBECONFIG_FILE}} build ks $(basename {{.path}}) \ - --namespace {{.ns}} \ - --kustomization-file {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml \ - --path {{.KUBERNETES_DIR}}/apps/{{.path}} \ - {{- if contains "not found" .ks }}--dry-run \{{ end }} - | \ - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side \ - --field-manager=kustomize-controller -f - - requires: - vars: ["path"] - vars: - ns: '{{.ns | default "flux-system"}}' - ks: - sh: flux --kubeconfig {{.KUBECONFIG_FILE}} --namespace {{.ns}} get kustomizations $(basename {{.path}}) 2>&1 - preconditions: - - msg: Missing kubeconfig - sh: test -f {{.KUBECONFIG_FILE}} - - msg: Missing Flux Kustomization for app {{.path}} - sh: test -f {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml + sh: test -f {{.SOPS_AGE_KEY_FILE}} reconcile: desc: Force update Flux to pull in changes from your Git repository - cmd: flux --kubeconfig {{.KUBECONFIG_FILE}} reconcile --namespace flux-system kustomization cluster --with-source + cmd: flux reconcile --namespace flux-system kustomization cluster --with-source preconditions: - msg: Missing kubeconfig - sh: test -f {{.KUBECONFIG_FILE}} + sh: test -f {{.KUBECONFIG}} github-deploy-key: cmds: - - kubectl create namespace flux-system --dry-run=client -o yaml | kubectl --kubeconfig {{.KUBECONFIG_FILE}} apply --filename - - - sops --decrypt {{.GITHUB_DEPLOY_KEY_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - + - kubectl create namespace flux-system --dry-run=client -o yaml | kubectl apply --filename - + - sops --decrypt {{.GITHUB_DEPLOY_KEY_FILE}} | kubectl apply --server-side --filename - preconditions: - msg: Missing kubeconfig - sh: test -f {{.KUBECONFIG_FILE}} + sh: test -f {{.KUBECONFIG}} - msg: Missing Sops Age key file - sh: test -f {{.AGE_FILE}} + sh: test -f {{.SOPS_AGE_KEY_FILE}} - msg: Missing Github deploy key file sh: test -f {{.GITHUB_DEPLOY_KEY_FILE}} diff --git a/.taskfiles/Kubernetes/Taskfile.yaml b/.taskfiles/Kubernetes/Taskfile.yaml index 872746e6..585b6946 100644 --- a/.taskfiles/Kubernetes/Taskfile.yaml +++ b/.taskfiles/Kubernetes/Taskfile.yaml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' vars: KUBECONFORM_SCRIPT: "{{.SCRIPTS_DIR}}/kubeconform.sh" @@ -10,10 +10,10 @@ tasks: resources: desc: Gather common resources in your cluster, useful when asking for support cmds: - - for: { var: resource } + - for: { var: RESOURCE } cmd: kubectl get {{.ITEM}} {{.CLI_ARGS | default "-A"}} vars: - resource: >- + RESOURCE: >- nodes gitrepositories kustomizations @@ -31,6 +31,6 @@ tasks: - msg: Missing kubeconform script sh: test -f {{.KUBECONFORM_SCRIPT}} - .reset: + reset: internal: true cmd: rm -rf {{.KUBERNETES_DIR}} diff --git a/.taskfiles/Repository/Taskfile.yaml b/.taskfiles/Repository/Taskfile.yaml index 9e6bae36..cbf29d35 100644 --- a/.taskfiles/Repository/Taskfile.yaml +++ b/.taskfiles/Repository/Taskfile.yaml @@ -1,6 +1,9 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' + +vars: + PRIVATE_DIR: '{{.ROOT_DIR}}/.private' tasks: @@ -26,18 +29,13 @@ tasks: sh: test -f {{.ROOT_DIR}}/.github/renovate.json5 reset: - desc: Reset templated configuration files + desc: Reset templated configuration files (use --force to reset repo back to HEAD) prompt: Reset templated configuration files... continue? cmds: - - task: :kubernetes:.reset - - task: :sops:.reset - - task: :talos:.reset - - force-reset: - desc: Reset repo back to HEAD - prompt: Reset repo back to HEAD... continue? - cmds: - - task: reset - - git reset --hard HEAD - - git clean -f -d - - git pull origin main + - task: :kubernetes:reset + - task: :sops:reset + - task: :talos:reset + - cmd: | + {{- if eq .CLI_FORCE true }} + git reset --hard HEAD && git clean -f -d && git pull origin main + {{- end }} diff --git a/.taskfiles/Sops/Taskfile.yaml b/.taskfiles/Sops/Taskfile.yaml index ff9342c9..c85ad482 100644 --- a/.taskfiles/Sops/Taskfile.yaml +++ b/.taskfiles/Sops/Taskfile.yaml @@ -1,13 +1,14 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' tasks: age-keygen: desc: Initialize Age Key for Sops - cmd: age-keygen --output {{.AGE_FILE}} - status: ["test -f {{.AGE_FILE}}"] + cmd: age-keygen --output {{.SOPS_AGE_KEY_FILE}} + status: + - test -f {{.SOPS_AGE_KEY_FILE}} encrypt: desc: Encrypt all Kubernetes SOPS secrets @@ -16,15 +17,15 @@ tasks: find "{{.KUBERNETES_DIR}}" -type f -name "*.sops.*" | while read -r file; do if sops filestatus "$file" | jq --exit-status ".encrypted == false" > /dev/null; then sops --encrypt --in-place "$file" - echo "Encrypted $file" + echo "Encrypted ${file}" fi done preconditions: - msg: Missing Sops config file sh: test -f {{.SOPS_CONFIG_FILE}} - msg: Missing Sops Age key file - sh: test -f {{.AGE_FILE}} + sh: test -f {{.SOPS_AGE_KEY_FILE}} - .reset: + reset: internal: true cmd: rm -rf {{.SOPS_CONFIG_FILE}} diff --git a/.taskfiles/Talos/Taskfile.yaml b/.taskfiles/Talos/Taskfile.yaml index a6ea10d5..9b1d5279 100644 --- a/.taskfiles/Talos/Taskfile.yaml +++ b/.taskfiles/Talos/Taskfile.yaml @@ -1,22 +1,21 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' vars: - TALHELPER_CLUSTER_DIR: "{{.KUBERNETES_DIR}}/bootstrap/talos/clusterconfig" - TALHELPER_SECRET_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talsecret.sops.yaml" - TALHELPER_CONFIG_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talconfig.yaml" - HELMFILE_FILE: "{{.KUBERNETES_DIR}}/bootstrap/helmfile.yaml" - TALOSCONFIG_FILE: "{{.TALHELPER_CLUSTER_DIR}}/talosconfig" + TALHELPER_CLUSTER_DIR: '{{.KUBERNETES_DIR}}/bootstrap/talos/clusterconfig' + TALHELPER_SECRET_FILE: '{{.KUBERNETES_DIR}}/bootstrap/talos/talsecret.sops.yaml' + TALHELPER_CONFIG_FILE: '{{.KUBERNETES_DIR}}/bootstrap/talos/talconfig.yaml' + HELMFILE_FILE: '{{.KUBERNETES_DIR}}/bootstrap/helmfile.yaml' env: - TALOSCONFIG: "{{.TALOSCONFIG_FILE}}" + TALOSCONFIG: '{{.TALHELPER_CLUSTER_DIR}}/talosconfig' tasks: bootstrap: desc: Bootstrap the Talos cluster - dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" + dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' cmds: - | if [ ! -f "{{.TALHELPER_SECRET_FILE}}" ]; then @@ -26,8 +25,8 @@ tasks: - talhelper genconfig --config-file {{.TALHELPER_CONFIG_FILE}} --secret-file {{.TALHELPER_SECRET_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} - talhelper gencommand apply --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="--insecure" | bash - until talhelper gencommand bootstrap --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} | bash; do sleep 10; done - - task: fetch-kubeconfig - - task: install-helm-apps + - task: conf + - task: apps - talosctl health --server=false preconditions: - msg: Missing talhelper config file @@ -35,42 +34,21 @@ tasks: - msg: Missing Sops config file sh: test -f {{.SOPS_CONFIG_FILE}} - msg: Missing Sops Age key file - sh: test -f {{.AGE_FILE}} - - fetch-kubeconfig: - desc: Fetch kubeconfig - dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" - cmd: until talhelper gencommand kubeconfig --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="{{.ROOT_DIR}} --force" | bash; do sleep 10; done - preconditions: - - msg: Missing talhelper config file - sh: test -f {{.TALHELPER_CONFIG_FILE}} - - install-helm-apps: - desc: Bootstrap core apps needed for Talos - dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" - cmds: - - until kubectl --kubeconfig {{.KUBECONFIG_FILE}} wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done - - helmfile --kubeconfig {{.KUBECONFIG_FILE}} --file {{.HELMFILE_FILE}} apply --skip-diff-on-install --suppress-diff - - until kubectl --kubeconfig {{.KUBECONFIG_FILE}} wait --for=condition=Ready nodes --all --timeout=600s; do sleep 10; done - preconditions: - - msg: Missing kubeconfig - sh: test -f {{.KUBECONFIG_FILE}} - - msg: Missing helmfile - sh: test -f {{.HELMFILE_FILE}} + sh: test -f {{.SOPS_AGE_KEY_FILE}} upgrade: desc: Upgrade Talos on a node - dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" + dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' cmds: - - talosctl --nodes {{.node}} upgrade --image {{.image}} --wait=true --timeout=10m --preserve=true --reboot-mode={{.mode}} - - talosctl --nodes {{.node}} health --wait-timeout=10m --server=false + - talosctl --nodes {{.NODE}} upgrade --image {{.IMAGE}} --wait=true --timeout=10m --preserve=true --reboot-mode={{.MODE}} + - talosctl --nodes {{.NODE}} health --wait-timeout=10m --server=false vars: - mode: '{{.mode | default "default"}}' + MODE: '{{.MODE | default "default"}}' requires: - vars: ["node", "image"] + vars: ['NODE', 'IMAGE'] preconditions: - msg: Missing talosconfig - sh: test -f {{.TALOSCONFIG_FILE}} + sh: test -f {{.TALOSCONFIG}} - msg: Unable to retrieve Talos config sh: talosctl config info >/dev/null 2>&1 - msg: Node not found @@ -78,17 +56,17 @@ tasks: upgrade-k8s: desc: Upgrade Kubernetes across the cluster - dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" - cmd: talosctl --nodes {{.controller}} upgrade-k8s --to {{.to}} + dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' + cmd: talosctl --nodes {{.CONTROLLER}} upgrade-k8s --to {{.TO}} requires: - vars: ["controller", "to"] + vars: ['CONTROLLER', 'TO'] preconditions: - msg: Missing talosconfig - sh: test -f {{.TALOSCONFIG_FILE}} + sh: test -f {{.TALOSCONFIG}} - msg: Unable to retrieve Talos config sh: talosctl config info >/dev/null 2>&1 - msg: Node not found - sh: talosctl --nodes {{.controller}} get machineconfig >/dev/null 2>&1 + sh: talosctl --nodes {{.CONTROLLER}} get machineconfig >/dev/null 2>&1 nuke: desc: Resets nodes back to maintenance mode @@ -96,6 +74,27 @@ tasks: prompt: This will destroy your cluster and reset the nodes back to maintenance mode... continue? cmd: talhelper gencommand reset --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="--reboot {{- if eq .CLI_FORCE false }} --system-labels-to-wipe STATE --system-labels-to-wipe EPHEMERAL{{ end }} --graceful=false --wait=false" | bash - .reset: + conf: + internal: true + dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' + cmd: until talhelper gencommand kubeconfig --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="{{.ROOT_DIR}} --force" | bash; do sleep 10; done + preconditions: + - msg: Missing talhelper config file + sh: test -f {{.TALHELPER_CONFIG_FILE}} + + apps: + internal: true + dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' + cmds: + - until kubectl wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done + - helmfile --file {{.HELMFILE_FILE}} apply --skip-diff-on-install --suppress-diff + - until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do sleep 10; done + preconditions: + - msg: Missing kubeconfig + sh: test -f {{.KUBECONFIG}} + - msg: Missing helmfile + sh: test -f {{.HELMFILE_FILE}} + + reset: internal: true cmd: rm -rf {{.TALHELPER_CLUSTER_DIR}} {{.TALHELPER_SECRET_FILE}} {{.TALHELPER_CONFIG_FILE}} diff --git a/.taskfiles/Workstation/Taskfile.yaml b/.taskfiles/Workstation/Taskfile.yaml index 09f309f6..894cab41 100644 --- a/.taskfiles/Workstation/Taskfile.yaml +++ b/.taskfiles/Workstation/Taskfile.yaml @@ -1,54 +1,46 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' vars: - ARCHFILE: "{{.ROOT_DIR}}/.taskfiles/Workstation/Archfile" - BREWFILE: "{{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile" - GENERIC_BIN_DIR: "{{.ROOT_DIR}}/.bin" + ARCHFILE: '{{.ROOT_DIR}}/.taskfiles/Workstation/Archfile' + BREWFILE: '{{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile' + GENERIC_BIN_DIR: '{{.ROOT_DIR}}/.bin' + PIP_REQUIREMENTS_FILE: '{{.ROOT_DIR}}/requirements.txt' + PYTHON_BIN: python3 tasks: - direnv: - desc: Run direnv hooks - cmd: direnv allow . - status: - - "[[ $(direnv status --json | jq '.state.foundRC.allowed') == 0 ]]" - - "[[ $(direnv status --json | jq '.state.loadedRC.allowed') == 0 ]]" - - venv: - desc: Set up virtual environment - cmds: - - "{{.PYTHON_BIN}} -m venv {{.VIRTUAL_ENV}}" - - '{{.VIRTUAL_ENV}}/bin/python3 -m pip install --upgrade pip setuptools wheel' - - '{{.VIRTUAL_ENV}}/bin/python3 -m pip install --upgrade --requirement "{{.PIP_REQUIREMENTS_FILE}}"' - sources: - - "{{.PIP_REQUIREMENTS_FILE}}" - generates: - - "{{.VIRTUAL_ENV}}/pyvenv.cfg" + arch: + desc: Install Arch workstation dependencies with Paru Or Yay + cmd: '{{.PKGMGR}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ARCHFILE}} | xargs)' + vars: + PKGMGR: + sh: command -v yay || command -v paru preconditions: - - { msg: "Missing Pip requirements file", sh: "test -f {{.PIP_REQUIREMENTS_FILE}}" } + - msg: Missing Archfile + sh: test -f {{.ARCHFILE}} brew: desc: Install workstation dependencies with Brew cmd: brew bundle --file {{.BREWFILE}} preconditions: - - { msg: "Missing Homebrew", sh: "command -v brew" } - - { msg: "Missing Brewfile", sh: "test -f {{.BREWFILE}}" } + - msg: Missing Homebrew + sh: command -v brew + - msg: Missing Brewfile + sh: test -f {{.BREWFILE}} - arch: - desc: Install Arch workstation dependencies with Paru Or Yay - cmd: "{{.helper}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ARCHFILE}} | xargs)" - vars: - helper: - sh: "command -v yay || command -v paru" - preconditions: - - { msg: "Missing Archfile", sh: "test -f {{.ARCHFILE}}" } + direnv: + desc: Run direnv hooks + cmd: direnv allow . + status: + - '[[ $(direnv status --json | jq ".state.foundRC.allowed") == 0 ]]' + - '[[ $(direnv status --json | jq ".state.loadedRC.allowed") == 0 ]]' generic-linux: - desc: Install CLI tools into the projects .bin directory using curl - dir: "{{.GENERIC_BIN_DIR}}" - platforms: ["linux/amd64", "linux/arm64"] + desc: Try to install CLI tools into the projects .bin directory + dir: '{{.GENERIC_BIN_DIR}}' + platforms: ['linux/amd64', 'linux/arm64'] cmds: - for: - budimanjojo/talhelper?as=talhelper&type=script @@ -64,8 +56,22 @@ tasks: - mikefarah/yq?as=yq&type=script cmd: curl -fsSL "https://i.jpillora.com/{{.ITEM}}" | bash - cmd: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" - platforms: ["linux/amd64"] + platforms: ['linux/amd64'] - cmd: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl" - platforms: ["linux/arm64"] + platforms: ['linux/arm64'] - cmd: chmod +x kubectl - cmd: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | USE_SUDO="false" HELM_INSTALL_DIR="." bash + + venv: + desc: Set up virtual environment + cmds: + - '{{.PYTHON_BIN}} -m venv {{.VIRTUAL_ENV}}' + - '{{.VIRTUAL_ENV}}/bin/python3 -m pip install --upgrade pip setuptools wheel' + - '{{.VIRTUAL_ENV}}/bin/python3 -m pip install --upgrade --requirement "{{.PIP_REQUIREMENTS_FILE}}"' + sources: + - '{{.PIP_REQUIREMENTS_FILE}}' + generates: + - '{{.VIRTUAL_ENV}}/pyvenv.cfg' + preconditions: + - msg: Missing Pip requirements file + sh: test -f {{.PIP_REQUIREMENTS_FILE}} diff --git a/Taskfile.yaml b/Taskfile.yaml index c812b9db..61775a26 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,28 +1,20 @@ --- # yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" +version: '3' vars: - # Directories - BOOTSTRAP_DIR: "{{.ROOT_DIR}}/bootstrap" - KUBERNETES_DIR: "{{.ROOT_DIR}}/kubernetes" - PRIVATE_DIR: "{{.ROOT_DIR}}/.private" - SCRIPTS_DIR: "{{.ROOT_DIR}}/scripts" - # Files - AGE_FILE: "{{.ROOT_DIR}}/age.key" - BOOTSTRAP_CONFIG_FILE: "{{.ROOT_DIR}}/config.yaml" - KUBECONFIG_FILE: "{{.ROOT_DIR}}/kubeconfig" - MAKEJINJA_CONFIG_FILE: "{{.ROOT_DIR}}/makejinja.toml" - PIP_REQUIREMENTS_FILE: "{{.ROOT_DIR}}/requirements.txt" - SOPS_CONFIG_FILE: "{{.ROOT_DIR}}/.sops.yaml" - # Binaries - PYTHON_BIN: python3 + BOOTSTRAP_DIR: '{{.ROOT_DIR}}/bootstrap' + KUBERNETES_DIR: '{{.ROOT_DIR}}/kubernetes' + SCRIPTS_DIR: '{{.ROOT_DIR}}/scripts' + BOOTSTRAP_CONFIG_FILE: '{{.ROOT_DIR}}/config.yaml' + MAKEJINJA_CONFIG_FILE: '{{.ROOT_DIR}}/makejinja.toml' + SOPS_CONFIG_FILE: '{{.ROOT_DIR}}/.sops.yaml' env: - KUBECONFIG: "{{.KUBECONFIG_FILE}}" - PYTHONDONTWRITEBYTECODE: "1" - SOPS_AGE_KEY_FILE: "{{.AGE_FILE}}" - VIRTUAL_ENV: "{{.ROOT_DIR}}/.venv" + KUBECONFIG: '{{.ROOT_DIR}}/kubeconfig' + PYTHONDONTWRITEBYTECODE: '1' + SOPS_AGE_KEY_FILE: '{{.ROOT_DIR}}/age.key' + VIRTUAL_ENV: '{{.ROOT_DIR}}/.venv' includes: kubernetes: .taskfiles/Kubernetes @@ -53,15 +45,15 @@ tasks: configure: desc: Configure repository from bootstrap vars prompt: Any conflicting config in the kubernetes directory will be overwritten... continue? - deps: ["workstation:direnv", "workstation:venv", "sops:age-keygen", "init"] + deps: ['workstation:direnv', 'workstation:venv', 'sops:age-keygen', 'init'] cmds: - - task: .template + - task: template - task: sops:encrypt - - task: .validate + - task: validate - .template: + template: internal: true - cmd: "{{.VIRTUAL_ENV}}/bin/makejinja" + cmd: '{{.VIRTUAL_ENV}}/bin/makejinja' preconditions: - msg: Missing virtual environment sh: test -d {{.VIRTUAL_ENV}} @@ -72,19 +64,11 @@ tasks: - msg: Missing bootstrap config file sh: test -f {{.BOOTSTRAP_CONFIG_FILE}} - .validate: + validate: internal: true cmds: - task: kubernetes:kubeconform - cmd: echo === Done rendering and validating YAML === - - cmd: | - if [[ $KUBECONFIG != "{{.KUBECONFIG_FILE}}" ]]; then - echo WARNING: KUBECONFIG is not set to the expected value, this may cause conflicts. - fi - - cmd: | - if [[ $SOPS_AGE_KEY_FILE != "{{.AGE_FILE}}" ]]; then - echo WARNING: SOPS_AGE_KEY_FILE is not set to the expected value, this may cause conflicts. - fi - cmd: | if test -f ~/.config/sops/age/keys.txt; then echo WARNING: SOPS Age key found in home directory, this may cause conflicts.