Skip to content

Commit

Permalink
fix: use requires in taskfiles when needed (#1201)
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Buhl <devin@buhl.casa>
  • Loading branch information
onedr0p committed Jan 19, 2024
1 parent a7c9827 commit 5a90397
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .taskfiles/Ansible/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ tasks:
prompt: Run Ansible playbook '{{.playbook}}'... continue?
deps: ["deps"]
cmd: .venv/bin/ansible-playbook --inventory {{.ANSIBLE_INVENTORY_FILE}} {{.ANSIBLE_DIR}}/playbooks/{{.playbook}}.yaml {{.CLI_ARGS}}
requires:
vars: ["playbook"]
preconditions:
- { msg: "Missing playbook arg", sh: "test -n {{.playbook}}" }
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }

poweroff:
Expand Down
4 changes: 2 additions & 2 deletions .taskfiles/Flux/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ tasks:
| \
kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side \
--field-manager=kustomize-controller -f -
requires:
vars: ["path", "ns"]
vars:
path: '{{ or .path (fail "Argument (path) is required") }}'
ns: '{{.ns | default "flux-system"}}'
ks:
sh: flux --kubeconfig {{.KUBECONFIG_FILE}} --namespace {{.ns}} get kustomizations $(basename {{.path}}) 2>&1
preconditions:
Expand Down
2 changes: 2 additions & 0 deletions .taskfiles/Sops/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ tasks:
.encrypt-file:
internal: true
cmd: sops --encrypt --in-place {{.file}}
requires:
vars: ["file"]
preconditions:
- { msg: "Missing Sops config file", sh: "test -f {{.SOPS_CONFIG_FILE}}" }
- { msg: "Missing Sops Age key file", sh: "test -f {{.SOPS_AGE_FILE}}" }
Expand Down
10 changes: 4 additions & 6 deletions .taskfiles/Talos/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ tasks:
upgrade-talos:
desc: Upgrade talos on a node
cmd: talosctl --nodes {{.node}} upgrade --image {{.image}} --preserve=true --reboot-mode=powercycle
vars:
image: '{{ or .image (fail "Argument (image) is required") }}'
node: '{{ or .node (fail "Argument (node) is required") }}'
requires:
vars: ["node", "to"]
preconditions:
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }

upgrade-k8s:
desc: Upgrade k8s on a node
cmd: talosctl --nodes {{.node}} upgrade-k8s --to {{.to}}
vars:
node: '{{ or .node (fail "Argument (node) is required") }}'
to: '{{ or .to (fail "Argument (to) is required") }}'
requires:
vars: ["node", "to"]
preconditions:
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }

0 comments on commit 5a90397

Please sign in to comment.