chore: update taskfiles and direnv (#1601)

This commit is contained in:
Devin Buhl authored and GitHub committed 2024-10-09 17:53:15 -04:00
1 parent be2819a84e
commit dd16fcd64b
8 files changed
+147 -183

No files matched your search

+3
View File
@@ -9,3 +9,6 @@ export PYTHONDONTWRITEBYTECODE="1"
export TALOSCONFIG="$(expand_path ./kubernetes/bootstrap/talos/clusterconfig/talosconfig)" export TALOSCONFIG="$(expand_path ./kubernetes/bootstrap/talos/clusterconfig/talosconfig)"
# Bin # Bin
PATH_add "$(expand_path ./.bin)" PATH_add "$(expand_path ./.bin)"
# Taskfile
export TASK_X_ENV_PRECEDENCE=1
export TASK_X_MAP_VARIABLES=0
+18 -45
View File
@@ -1,75 +1,48 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars: vars:
CLUSTER_SECRET_SOPS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml" CLUSTER_SECRET_SOPS_FILE: '{{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml'
CLUSTER_SETTINGS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml" CLUSTER_SETTINGS_FILE: '{{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml'
GITHUB_DEPLOY_KEY_FILE: "{{.KUBERNETES_DIR}}/bootstrap/flux/github-deploy-key.sops.yaml" GITHUB_DEPLOY_KEY_FILE: '{{.KUBERNETES_DIR}}/bootstrap/flux/github-deploy-key.sops.yaml'
tasks: tasks:
bootstrap: bootstrap:
desc: Bootstrap Flux into a Kubernetes cluster desc: Bootstrap Flux into a Kubernetes cluster
cmds: 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 if ! kubectl --namespace 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 cat {{.SOPS_AGE_KEY_FILE}} | kubectl --namespace flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin
else else
echo "sops-age secret already exists, skipping creation." echo "sops-age secret already exists, skipping creation."
fi fi
- sops --decrypt {{.CLUSTER_SECRET_SOPS_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - - sops --decrypt {{.CLUSTER_SECRET_SOPS_FILE}} | kubectl apply --server-side --filename -
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_FILE}} - kubectl apply --server-side --filename {{.CLUSTER_SETTINGS_FILE}}
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config - kubectl apply --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config
preconditions: preconditions:
- msg: Missing kubeconfig - msg: Missing kubeconfig
sh: test -f {{.KUBECONFIG_FILE}} sh: test -f {{.KUBECONFIG}}
- msg: Missing Sops Age key file - msg: Missing Sops Age key file
sh: test -f {{.AGE_FILE}} sh: test -f {{.SOPS_AGE_KEY_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
reconcile: reconcile:
desc: Force update Flux to pull in changes from your Git repository 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: preconditions:
- msg: Missing kubeconfig - msg: Missing kubeconfig
sh: test -f {{.KUBECONFIG_FILE}} sh: test -f {{.KUBECONFIG}}
github-deploy-key: github-deploy-key:
cmds: cmds:
- kubectl create namespace flux-system --dry-run=client -o yaml | kubectl --kubeconfig {{.KUBECONFIG_FILE}} apply --filename - - kubectl create namespace flux-system --dry-run=client -o yaml | kubectl apply --filename -
- sops --decrypt {{.GITHUB_DEPLOY_KEY_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - - sops --decrypt {{.GITHUB_DEPLOY_KEY_FILE}} | kubectl apply --server-side --filename -
preconditions: preconditions:
- msg: Missing kubeconfig - msg: Missing kubeconfig
sh: test -f {{.KUBECONFIG_FILE}} sh: test -f {{.KUBECONFIG}}
- msg: Missing Sops Age key file - msg: Missing Sops Age key file
sh: test -f {{.AGE_FILE}} sh: test -f {{.SOPS_AGE_KEY_FILE}}
- msg: Missing Github deploy key file - msg: Missing Github deploy key file
sh: test -f {{.GITHUB_DEPLOY_KEY_FILE}} sh: test -f {{.GITHUB_DEPLOY_KEY_FILE}}
+4 -4
View File
@@ -1,6 +1,6 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars: vars:
KUBECONFORM_SCRIPT: "{{.SCRIPTS_DIR}}/kubeconform.sh" KUBECONFORM_SCRIPT: "{{.SCRIPTS_DIR}}/kubeconform.sh"
@@ -10,10 +10,10 @@ tasks:
resources: resources:
desc: Gather common resources in your cluster, useful when asking for support desc: Gather common resources in your cluster, useful when asking for support
cmds: cmds:
- for: { var: resource } - for: { var: RESOURCE }
cmd: kubectl get {{.ITEM}} {{.CLI_ARGS | default "-A"}} cmd: kubectl get {{.ITEM}} {{.CLI_ARGS | default "-A"}}
vars: vars:
resource: >- RESOURCE: >-
nodes nodes
gitrepositories gitrepositories
kustomizations kustomizations
@@ -31,6 +31,6 @@ tasks:
- msg: Missing kubeconform script - msg: Missing kubeconform script
sh: test -f {{.KUBECONFORM_SCRIPT}} sh: test -f {{.KUBECONFORM_SCRIPT}}
.reset: reset:
internal: true internal: true
cmd: rm -rf {{.KUBERNETES_DIR}} cmd: rm -rf {{.KUBERNETES_DIR}}
+12 -14
View File
@@ -1,6 +1,9 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars:
PRIVATE_DIR: '{{.ROOT_DIR}}/.private'
tasks: tasks:
@@ -26,18 +29,13 @@ tasks:
sh: test -f {{.ROOT_DIR}}/.github/renovate.json5 sh: test -f {{.ROOT_DIR}}/.github/renovate.json5
reset: 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? prompt: Reset templated configuration files... continue?
cmds: cmds:
- task: :kubernetes:.reset - task: :kubernetes:reset
- task: :sops:.reset - task: :sops:reset
- task: :talos:.reset - task: :talos:reset
- cmd: |
force-reset: {{- if eq .CLI_FORCE true }}
desc: Reset repo back to HEAD git reset --hard HEAD && git clean -f -d && git pull origin main
prompt: Reset repo back to HEAD... continue? {{- end }}
cmds:
- task: reset
- git reset --hard HEAD
- git clean -f -d
- git pull origin main
+7 -6
View File
@@ -1,13 +1,14 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
tasks: tasks:
age-keygen: age-keygen:
desc: Initialize Age Key for Sops desc: Initialize Age Key for Sops
cmd: age-keygen --output {{.AGE_FILE}} cmd: age-keygen --output {{.SOPS_AGE_KEY_FILE}}
status: ["test -f {{.AGE_FILE}}"] status:
- test -f {{.SOPS_AGE_KEY_FILE}}
encrypt: encrypt:
desc: Encrypt all Kubernetes SOPS secrets desc: Encrypt all Kubernetes SOPS secrets
@@ -16,15 +17,15 @@ tasks:
find "{{.KUBERNETES_DIR}}" -type f -name "*.sops.*" | while read -r file; do find "{{.KUBERNETES_DIR}}" -type f -name "*.sops.*" | while read -r file; do
if sops filestatus "$file" | jq --exit-status ".encrypted == false" > /dev/null; then if sops filestatus "$file" | jq --exit-status ".encrypted == false" > /dev/null; then
sops --encrypt --in-place "$file" sops --encrypt --in-place "$file"
echo "Encrypted $file" echo "Encrypted ${file}"
fi fi
done done
preconditions: preconditions:
- msg: Missing Sops config file - msg: Missing Sops config file
sh: test -f {{.SOPS_CONFIG_FILE}} sh: test -f {{.SOPS_CONFIG_FILE}}
- msg: Missing Sops Age key file - msg: Missing Sops Age key file
sh: test -f {{.AGE_FILE}} sh: test -f {{.SOPS_AGE_KEY_FILE}}
.reset: reset:
internal: true internal: true
cmd: rm -rf {{.SOPS_CONFIG_FILE}} cmd: rm -rf {{.SOPS_CONFIG_FILE}}
+43 -44
View File
@@ -1,22 +1,21 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars: vars:
TALHELPER_CLUSTER_DIR: "{{.KUBERNETES_DIR}}/bootstrap/talos/clusterconfig" TALHELPER_CLUSTER_DIR: '{{.KUBERNETES_DIR}}/bootstrap/talos/clusterconfig'
TALHELPER_SECRET_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talsecret.sops.yaml" TALHELPER_SECRET_FILE: '{{.KUBERNETES_DIR}}/bootstrap/talos/talsecret.sops.yaml'
TALHELPER_CONFIG_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talconfig.yaml" TALHELPER_CONFIG_FILE: '{{.KUBERNETES_DIR}}/bootstrap/talos/talconfig.yaml'
HELMFILE_FILE: "{{.KUBERNETES_DIR}}/bootstrap/helmfile.yaml" HELMFILE_FILE: '{{.KUBERNETES_DIR}}/bootstrap/helmfile.yaml'
TALOSCONFIG_FILE: "{{.TALHELPER_CLUSTER_DIR}}/talosconfig"
env: env:
TALOSCONFIG: "{{.TALOSCONFIG_FILE}}" TALOSCONFIG: '{{.TALHELPER_CLUSTER_DIR}}/talosconfig'
tasks: tasks:
bootstrap: bootstrap:
desc: Bootstrap the Talos cluster desc: Bootstrap the Talos cluster
dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" dir: '{{.KUBERNETES_DIR}}/bootstrap/talos'
cmds: cmds:
- | - |
if [ ! -f "{{.TALHELPER_SECRET_FILE}}" ]; then 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 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 - 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 - until talhelper gencommand bootstrap --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} | bash; do sleep 10; done
- task: fetch-kubeconfig - task: conf
- task: install-helm-apps - task: apps
- talosctl health --server=false - talosctl health --server=false
preconditions: preconditions:
- msg: Missing talhelper config file - msg: Missing talhelper config file
@@ -35,42 +34,21 @@ tasks:
- msg: Missing Sops config file - msg: Missing Sops config file
sh: test -f {{.SOPS_CONFIG_FILE}} sh: test -f {{.SOPS_CONFIG_FILE}}
- msg: Missing Sops Age key file - msg: Missing Sops Age key file
sh: test -f {{.AGE_FILE}} sh: test -f {{.SOPS_AGE_KEY_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}}
upgrade: upgrade:
desc: Upgrade Talos on a node desc: Upgrade Talos on a node
dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" dir: '{{.KUBERNETES_DIR}}/bootstrap/talos'
cmds: cmds:
- talosctl --nodes {{.node}} upgrade --image {{.image}} --wait=true --timeout=10m --preserve=true --reboot-mode={{.mode}} - 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}} health --wait-timeout=10m --server=false
vars: vars:
mode: '{{.mode | default "default"}}' MODE: '{{.MODE | default "default"}}'
requires: requires:
vars: ["node", "image"] vars: ['NODE', 'IMAGE']
preconditions: preconditions:
- msg: Missing talosconfig - msg: Missing talosconfig
sh: test -f {{.TALOSCONFIG_FILE}} sh: test -f {{.TALOSCONFIG}}
- msg: Unable to retrieve Talos config - msg: Unable to retrieve Talos config
sh: talosctl config info >/dev/null 2>&1 sh: talosctl config info >/dev/null 2>&1
- msg: Node not found - msg: Node not found
@@ -78,17 +56,17 @@ tasks:
upgrade-k8s: upgrade-k8s:
desc: Upgrade Kubernetes across the cluster desc: Upgrade Kubernetes across the cluster
dir: "{{.KUBERNETES_DIR}}/bootstrap/talos" dir: '{{.KUBERNETES_DIR}}/bootstrap/talos'
cmd: talosctl --nodes {{.controller}} upgrade-k8s --to {{.to}} cmd: talosctl --nodes {{.CONTROLLER}} upgrade-k8s --to {{.TO}}
requires: requires:
vars: ["controller", "to"] vars: ['CONTROLLER', 'TO']
preconditions: preconditions:
- msg: Missing talosconfig - msg: Missing talosconfig
sh: test -f {{.TALOSCONFIG_FILE}} sh: test -f {{.TALOSCONFIG}}
- msg: Unable to retrieve Talos config - msg: Unable to retrieve Talos config
sh: talosctl config info >/dev/null 2>&1 sh: talosctl config info >/dev/null 2>&1
- msg: Node not found - 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: nuke:
desc: Resets nodes back to maintenance mode 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? 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 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 internal: true
cmd: rm -rf {{.TALHELPER_CLUSTER_DIR}} {{.TALHELPER_SECRET_FILE}} {{.TALHELPER_CONFIG_FILE}} cmd: rm -rf {{.TALHELPER_CLUSTER_DIR}} {{.TALHELPER_SECRET_FILE}} {{.TALHELPER_CONFIG_FILE}}
+43 -37
View File
@@ -1,54 +1,46 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars: vars:
ARCHFILE: "{{.ROOT_DIR}}/.taskfiles/Workstation/Archfile" ARCHFILE: '{{.ROOT_DIR}}/.taskfiles/Workstation/Archfile'
BREWFILE: "{{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile" BREWFILE: '{{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile'
GENERIC_BIN_DIR: "{{.ROOT_DIR}}/.bin" GENERIC_BIN_DIR: '{{.ROOT_DIR}}/.bin'
PIP_REQUIREMENTS_FILE: '{{.ROOT_DIR}}/requirements.txt'
PYTHON_BIN: python3
tasks: tasks:
direnv: arch:
desc: Run direnv hooks desc: Install Arch workstation dependencies with Paru Or Yay
cmd: direnv allow . cmd: '{{.PKGMGR}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ARCHFILE}} | xargs)'
status: vars:
- "[[ $(direnv status --json | jq '.state.foundRC.allowed') == 0 ]]" PKGMGR:
- "[[ $(direnv status --json | jq '.state.loadedRC.allowed') == 0 ]]" sh: command -v yay || command -v paru
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: preconditions:
- { msg: "Missing Pip requirements file", sh: "test -f {{.PIP_REQUIREMENTS_FILE}}" } - msg: Missing Archfile
sh: test -f {{.ARCHFILE}}
brew: brew:
desc: Install workstation dependencies with Brew desc: Install workstation dependencies with Brew
cmd: brew bundle --file {{.BREWFILE}} cmd: brew bundle --file {{.BREWFILE}}
preconditions: preconditions:
- { msg: "Missing Homebrew", sh: "command -v brew" } - msg: Missing Homebrew
- { msg: "Missing Brewfile", sh: "test -f {{.BREWFILE}}" } sh: command -v brew
- msg: Missing Brewfile
sh: test -f {{.BREWFILE}}
arch: direnv:
desc: Install Arch workstation dependencies with Paru Or Yay desc: Run direnv hooks
cmd: "{{.helper}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ARCHFILE}} | xargs)" cmd: direnv allow .
vars: status:
helper: - '[[ $(direnv status --json | jq ".state.foundRC.allowed") == 0 ]]'
sh: "command -v yay || command -v paru" - '[[ $(direnv status --json | jq ".state.loadedRC.allowed") == 0 ]]'
preconditions:
- { msg: "Missing Archfile", sh: "test -f {{.ARCHFILE}}" }
generic-linux: generic-linux:
desc: Install CLI tools into the projects .bin directory using curl desc: Try to install CLI tools into the projects .bin directory
dir: "{{.GENERIC_BIN_DIR}}" dir: '{{.GENERIC_BIN_DIR}}'
platforms: ["linux/amd64", "linux/arm64"] platforms: ['linux/amd64', 'linux/arm64']
cmds: cmds:
- for: - for:
- budimanjojo/talhelper?as=talhelper&type=script - budimanjojo/talhelper?as=talhelper&type=script
@@ -64,8 +56,22 @@ tasks:
- mikefarah/yq?as=yq&type=script - mikefarah/yq?as=yq&type=script
cmd: curl -fsSL "https://i.jpillora.com/{{.ITEM}}" | bash 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" - 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" - 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: chmod +x kubectl
- cmd: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | USE_SUDO="false" HELM_INSTALL_DIR="." bash - 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}}
+17 -33
View File
@@ -1,28 +1,20 @@
--- ---
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3" version: '3'
vars: vars:
# Directories BOOTSTRAP_DIR: '{{.ROOT_DIR}}/bootstrap'
BOOTSTRAP_DIR: "{{.ROOT_DIR}}/bootstrap" KUBERNETES_DIR: '{{.ROOT_DIR}}/kubernetes'
KUBERNETES_DIR: "{{.ROOT_DIR}}/kubernetes" SCRIPTS_DIR: '{{.ROOT_DIR}}/scripts'
PRIVATE_DIR: "{{.ROOT_DIR}}/.private" BOOTSTRAP_CONFIG_FILE: '{{.ROOT_DIR}}/config.yaml'
SCRIPTS_DIR: "{{.ROOT_DIR}}/scripts" MAKEJINJA_CONFIG_FILE: '{{.ROOT_DIR}}/makejinja.toml'
# Files SOPS_CONFIG_FILE: '{{.ROOT_DIR}}/.sops.yaml'
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
env: env:
KUBECONFIG: "{{.KUBECONFIG_FILE}}" KUBECONFIG: '{{.ROOT_DIR}}/kubeconfig'
PYTHONDONTWRITEBYTECODE: "1" PYTHONDONTWRITEBYTECODE: '1'
SOPS_AGE_KEY_FILE: "{{.AGE_FILE}}" SOPS_AGE_KEY_FILE: '{{.ROOT_DIR}}/age.key'
VIRTUAL_ENV: "{{.ROOT_DIR}}/.venv" VIRTUAL_ENV: '{{.ROOT_DIR}}/.venv'
includes: includes:
kubernetes: .taskfiles/Kubernetes kubernetes: .taskfiles/Kubernetes
@@ -53,15 +45,15 @@ tasks:
configure: configure:
desc: Configure repository from bootstrap vars desc: Configure repository from bootstrap vars
prompt: Any conflicting config in the kubernetes directory will be overwritten... continue? 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: cmds:
- task: .template - task: template
- task: sops:encrypt - task: sops:encrypt
- task: .validate - task: validate
.template: template:
internal: true internal: true
cmd: "{{.VIRTUAL_ENV}}/bin/makejinja" cmd: '{{.VIRTUAL_ENV}}/bin/makejinja'
preconditions: preconditions:
- msg: Missing virtual environment - msg: Missing virtual environment
sh: test -d {{.VIRTUAL_ENV}} sh: test -d {{.VIRTUAL_ENV}}
@@ -72,19 +64,11 @@ tasks:
- msg: Missing bootstrap config file - msg: Missing bootstrap config file
sh: test -f {{.BOOTSTRAP_CONFIG_FILE}} sh: test -f {{.BOOTSTRAP_CONFIG_FILE}}
.validate: validate:
internal: true internal: true
cmds: cmds:
- task: kubernetes:kubeconform - task: kubernetes:kubeconform
- cmd: echo === Done rendering and validating YAML === - 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: | - cmd: |
if test -f ~/.config/sops/age/keys.txt; then if test -f ~/.config/sops/age/keys.txt; then
echo WARNING: SOPS Age key found in home directory, this may cause conflicts. echo WARNING: SOPS Age key found in home directory, this may cause conflicts.