fix: Updates to taskfiles and e2e workflow (#1144)

This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-13 12:04:44 -05:00
1 parent 0ddfc8db3b
commit 3b1ea970b1
15 files changed
+196 -104

No files matched your search

@@ -4,6 +4,7 @@ version: "3"
vars:
PYTHON_BIN: python3
ANSIBLE_INVENTORY_FILE: "{{.ANSIBLE_DIR}}/inventory/hosts.yaml"
env:
PATH: "{{.ROOT_DIR}}/.venv/bin:$PATH"
@@ -11,6 +12,8 @@ env:
ANSIBLE_COLLECTIONS_PATH: "{{.ROOT_DIR}}/.venv/galaxy"
ANSIBLE_ROLES_PATH: "{{.ROOT_DIR}}/.venv/galaxy/ansible_roles"
ANSIBLE_VARS_ENABLED: "host_group_vars,community.sops.sops"
ANSIBLE_LOCALHOST_WARNING: "False"
ANSIBLE_INVENTORY_UNPARSED_WARNING: "False"
tasks:
@@ -18,6 +21,8 @@ tasks:
desc: Set up Ansible dependencies for the environment
cmds:
- task: .venv
vars:
force: '{{.force | default "true"}}'
run:
desc: Run an Ansible playbook for configuring a cluster
@@ -27,46 +32,53 @@ tasks:
prompt: Run Ansible playbook '{{.playbook}}'... continue?
deps: ["deps"]
cmd: |
.venv/bin/ansible-playbook \
--inventory {{.ANSIBLE_DIR}}/inventory/hosts.yaml \
{{.ANSIBLE_DIR}}/playbooks/{{.playbook}}.yaml {{.CLI_ARGS}}
.venv/bin/ansible-playbook --inventory {{.ANSIBLE_INVENTORY_FILE}} \
{{.ANSIBLE_DIR}}/playbooks/{{.playbook}}.yaml {{.CLI_ARGS}}
preconditions:
- { msg: "Argument (playbook) is required", sh: "test -n {{.playbook}}" }
- { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
- { msg: "Playbook not found", sh: "test -f {{.ANSIBLE_DIR}}/playbooks/{{.playbook}}.yaml" }
poweroff:
desc: Shutdown all the k8s nodes
deps: ["deps"]
cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml -a '/usr/bin/systemctl poweroff' --become
cmd: |
.venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} \
-a '/usr/bin/systemctl poweroff' --become
preconditions:
- { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
list:
desc: List all the hosts
deps: ["deps"]
cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --list-hosts
cmd: |
.venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} \
--list-hosts
preconditions:
- { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
ping:
desc: Ping all the hosts
deps: ["deps"]
cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --one-line -m 'ping'
cmd: |
.venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} \
--one-line -m 'ping'
preconditions:
- { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
uptime:
desc: Uptime of all the hosts
deps: ["deps"]
cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --one-line -a 'uptime'
cmd: |
.venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} \
--one-line -a 'uptime'
preconditions:
- { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" }
- { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
.venv:
internal: true
@@ -74,7 +86,9 @@ tasks:
- true && {{.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 "{{.ROOT_DIR}}/requirements.txt"
- .venv/bin/ansible-galaxy install --role-file "{{.ROOT_DIR}}/requirements.yaml" --force
- .venv/bin/ansible-galaxy install --role-file "{{.ROOT_DIR}}/requirements.yaml" {{if eq .force "true"}}--force{{end}}
vars:
force: '{{.force | default "true"}}'
sources:
- "{{.ANSIBLE_DIR}}/requirements.txt"
- "{{.ANSIBLE_DIR}}/requirements.yaml"
-33
View File
@@ -1,33 +0,0 @@
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
tasks:
deps:
desc: Install workstation dependencies with Brew
cmd: brew install {{.DEPS}} {{.CLI_ARGS}}
vars:
DEPS: >-
age
cilium-cli
cloudflared
direnv
fluxcd/tap/flux
helm
jq
k0sproject/tap/k0sctl
k9s
kubeconform
kubecolor/tap/kubecolor
kubernetes-cli
kustomize
moreutils
sops
stern
yq
preconditions:
- sh: command -v brew
msg: |
Homebrew is not installed. Using MacOS, Linux or WSL?
Head over to https://brew.sh to get up and running.
@@ -57,7 +57,6 @@ tasks:
cmd: flux reconcile --namespace flux-system kustomization cluster --with-source
github-deploy-key:
cmds:
- sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --server-side --filename -
cmd: sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --server-side --filename -
preconditions:
- { msg: "Flux is not installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 0 || exit 1" }
File renamed without changes.
File renamed without changes.
@@ -12,7 +12,7 @@ tasks:
- rm -rf {{.ROOT_DIR}}/.github/workflows/e2e.yaml
# Move bootstrap directory to gitignored directory
- mkdir -p {{.ROOT_DIR}}/.private
- mv {{.ROOT_DIR}}/bootstrap {{.ROOT_DIR}}/.private
- mv {{.ROOT_DIR}}/bootstrap {{.ROOT_DIR}}/.private/bootstrap-{{now | date "150405"}}
# Update renovate.json5
- sed -i {{if eq OS "darwin"}}''{{end}} 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT_DIR}}/.github/renovate.json5
- sed -i {{if eq OS "darwin"}}''{{end}} '/addons/d' {{.ROOT_DIR}}/.github/renovate.json5
@@ -4,14 +4,15 @@ version: "3"
tasks:
init:
desc: Initialize Sops Age Key
age-keygen:
desc: Initialize Age Key for Sops
cmd: age-keygen --output {{.ROOT_DIR}}/age.key
status:
- test -f "{{.ROOT_DIR}}/age.key"
encrypt:
desc: Encrypt a secret
aliases: ["e"]
summary: |
Args:
file: Path to file to encrypt (required)
@@ -24,6 +25,7 @@ tasks:
decrypt:
desc: Decrypt a secret
aliases: ["d"]
summary: |
Args:
file: Path to file to decrypt (required)
+17
View File
@@ -0,0 +1,17 @@
age
cilium-cli
cloudflared-bin
direnv
flux-bin
helm
jq
k0sctl-bin
k9s
kubeconform
kubectl-bin
kustomize
moreutils
sops
stern-bin
go-task
go-yq
+21
View File
@@ -0,0 +1,21 @@
tap "fluxcd/tap"
tap "go-task/tap"
tap "k0sproject/tap"
tap "kubecolor/tap"
brew "age"
brew "cilium-cli"
brew "cloudflared"
brew "direnv"
brew "fluxcd/tap/flux"
brew "helm"
brew "jq"
brew "k0sproject/tap/k0sctl"
brew "k9s"
brew "kubeconform"
brew "kubecolor/tap/kubecolor"
brew "kubernetes-cli"
brew "kustomize"
brew "moreutils"
brew "sops"
brew "stern"
brew "yq"
+25
View File
@@ -0,0 +1,25 @@
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
tasks:
brew:
desc: Install workstation dependencies with Brew
cmd: brew bundle --file {{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile
preconditions:
- sh: command -v brew
msg: |
Homebrew is not installed. Using MacOS, Linux or WSL?
Head over to https://brew.sh to get up and running.
- { msg: "Brewfile not found", sh: "test -f {{.ROOT_DIR}}/.taskfiles/Workstation/Brewfile" }
yay:
desc: Install workstation dependencies with Paru
cmd: yay -Syu --needed --noconfirm --noprogressbar $(cat {{.ROOT_DIR}}/.taskfiles/Workstation/ArchPackages | xargs)
preconditions:
- sh: command -v yay
msg: |
Yay is not installed. Using ArchLinux?
Head over to https://github.com/Jguer/yay to get up and running.
- { msg: "ArchPackages not found", sh: "test -f {{.ROOT_DIR}}/.taskfiles/Workstation/ArchPackages" }