From 7bd55db9953e4480f1c086e7b8992a54cbde1b53 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 12 Jan 2024 16:23:14 -0500 Subject: [PATCH] fix: ansible taskfile ad-hoc tasks now have preconditions Signed-off-by: Devin Buhl --- .taskfiles/AnsibleTasks.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.taskfiles/AnsibleTasks.yaml b/.taskfiles/AnsibleTasks.yaml index a59540ff..4b3169a1 100644 --- a/.taskfiles/AnsibleTasks.yaml +++ b/.taskfiles/AnsibleTasks.yaml @@ -40,21 +40,33 @@ tasks: 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 + preconditions: + - { msg: "Venv not found", sh: "test -d {{.ROOT_DIR}}/.venv" } + - { msg: "Inventory not found", sh: "test -f {{.ANSIBLE_DIR}}/inventory/hosts.yaml" } list: desc: List all the hosts deps: ["deps"] cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --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" } ping: desc: Ping all the hosts deps: ["deps"] cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --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" } uptime: desc: Uptime of all the hosts deps: ["deps"] cmd: .venv/bin/ansible kubernetes -i {{.ANSIBLE_DIR}}/inventory/hosts.yaml --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" } .venv: internal: true