* chore: improvements to e2e workflow Signed-off-by: Devin Buhl <devin@buhl.casa> * chore: improve taskfiles Signed-off-by: Devin Buhl <devin@buhl.casa> * chore: update taskfiles Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
91 lines
3.3 KiB
YAML
91 lines
3.3 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
|
version: "3"
|
|
|
|
env:
|
|
PATH: "{{.ROOT_DIR}}/.venv/bin:$PATH"
|
|
VIRTUAL_ENV: "{{.ROOT_DIR}}/.venv"
|
|
ANSIBLE_COLLECTIONS_PATH: "{{.ROOT_DIR}}/.venv/galaxy"
|
|
ANSIBLE_ROLES_PATH: "{{.ROOT_DIR}}/.venv/galaxy/ansible_roles"
|
|
ANSIBLE_VARS_ENABLED: "host_group_vars"
|
|
ANSIBLE_LOCALHOST_WARNING: "False"
|
|
ANSIBLE_INVENTORY_UNPARSED_WARNING: "False"
|
|
|
|
vars:
|
|
ANSIBLE_LINT_FILE: "{{.ANSIBLE_DIR}}/.ansible-lint"
|
|
ANSIBLE_INVENTORY_FILE: "{{.ANSIBLE_DIR}}/inventory/hosts.yaml"
|
|
ANSIBLE_REQUIREMENTS_FILE: "{{.ANSIBLE_DIR}}/requirements.yaml"
|
|
ANSIBLE_PIP_REQUIREMENTS_FILE: "{{.ANSIBLE_DIR}}/requirements.txt"
|
|
|
|
tasks:
|
|
|
|
deps:
|
|
desc: Set up Ansible dependencies
|
|
deps: [":workstation:venv"]
|
|
cmds:
|
|
- .venv/bin/python3 -m pip install --upgrade --requirement "{{.ANSIBLE_PIP_REQUIREMENTS_FILE}}"
|
|
- .venv/bin/ansible-galaxy install --role-file "{{.ANSIBLE_REQUIREMENTS_FILE}}" {{if eq .force "true"}}--force{{end}}
|
|
preconditions:
|
|
- { msg: "Missing Ansible requirements file", sh: "test -f {{.ANSIBLE_REQUIREMENTS_FILE}}" }
|
|
- { msg: "Missing Pip requirements file", sh: "test -f {{.ANSIBLE_PIP_REQUIREMENTS_FILE}}" }
|
|
sources:
|
|
- "{{.ANSIBLE_REQUIREMENTS_FILE}}"
|
|
- "{{.ANSIBLE_PIP_REQUIREMENTS_FILE}}"
|
|
generates:
|
|
- "{{.VIRTUAL_ENV}}/bin/ansible"
|
|
- "{{.VIRTUAL_ENV}}/bin/ansible-galaxy"
|
|
vars:
|
|
force: '{{.force | default "true"}}'
|
|
|
|
run:
|
|
desc: Run an Ansible playbook for configuring a cluster
|
|
summary: |
|
|
Args:
|
|
playbook: Playbook to run (required)
|
|
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 Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
|
|
|
poweroff:
|
|
desc: Shutdown all the k8s nodes
|
|
deps: ["deps"]
|
|
cmd: .venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} -a '/usr/bin/systemctl poweroff' --become
|
|
preconditions:
|
|
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
|
|
|
list:
|
|
desc: List all the hosts
|
|
deps: ["deps"]
|
|
cmd: .venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --list-hosts
|
|
preconditions:
|
|
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
|
|
|
ping:
|
|
desc: Ping all the hosts
|
|
deps: ["deps"]
|
|
cmd: .venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --one-line -m 'ping'
|
|
preconditions:
|
|
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
|
|
|
uptime:
|
|
desc: Uptime of all the hosts
|
|
deps: ["deps"]
|
|
cmd: .venv/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --one-line -a 'uptime'
|
|
preconditions:
|
|
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
|
|
|
lint:
|
|
desc: Lint Ansible
|
|
deps: ["deps"]
|
|
cmd: ./.venv/bin/ansible-lint --config-file {{.ANSIBLE_LINT_FILE}} {{.ANSIBLE_DIR}}/**/*.yaml
|
|
preconditions:
|
|
- { msg: "Missing Ansible lint file", sh: "test -f {{.ANSIBLE_LINT_FILE}}" }
|
|
|
|
.reset:
|
|
internal: true
|
|
cmd: rm -rf {{.ANSIBLE_DIR}}
|