refactor: install ansible with Python venv (#863)

This commit is contained in:
Devin Buhl authored and GitHub committed 2023-07-19 11:03:59 -04:00
1 parent e4d1fa15d6
commit 571a7454c0
15 files changed
+85 -153

No files matched your search

+15 -56
View File
@@ -1,95 +1,54 @@
---
version: "3"
env:
K8S_AUTH_KUBECONFIG: "{{.ROOT_DIR}}/kubeconfig"
vars:
ANSIBLE_PLAYBOOK_DIR: "{{.ANSIBLE_DIR}}/playbooks"
ANSIBLE_INVENTORY_DIR: "{{.ANSIBLE_DIR}}/inventory"
tasks:
deps:
desc: Install / Upgrade Ansible galaxy deps
dir: "{{.ANSIBLE_DIR}}"
cmds:
- pip3 install --user --requirement requirements.txt
- ansible-galaxy install -r requirements.yaml --roles-path ~/.ansible/roles --force
- ansible-galaxy collection install -r requirements.yaml --collections-path ~/.ansible/collections --force
preconditions:
- test -f "{{.ANSIBLE_DIR}}/requirements.txt"
- test -f "{{.ANSIBLE_DIR}}/requirements.yaml"
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
list:
desc: List all the hosts
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --list-hosts
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
prepare:
desc: Prepare all the k8s nodes for running k3s
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-prepare.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
install:
desc: Install Kubernetes on the nodes
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-installation.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
rollout-update:
desc: Preform operating system updates and rollout restart the cluster
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-rollout-update.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
kube-vip:
desc: Apply new kube-vip configuration to the cluster
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-kube-vip.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
nuke:
desc: Uninstall Kubernetes on the nodes
dir: "{{.ANSIBLE_DIR}}"
interactive: true
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-nuke.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
reboot:
desc: Reboot all the k8s nodes
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-reboot.yaml
poweroff:
desc: Shutdown all the k8s nodes
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml -a '/usr/bin/systemctl poweroff' --become
list:
desc: List all the hosts
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --list-hosts
ping:
desc: Ping all the hosts
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --one-line -m 'ping'
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
uptime:
desc: Uptime of all the hosts
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible all -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml --one-line -a 'uptime'
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
force-reboot:
desc: Reboot all the k8s nodes
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible-playbook -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml {{.ANSIBLE_PLAYBOOK_DIR}}/cluster-reboot.yaml
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
force-poweroff:
desc: Shutdown all the k8s nodes
dir: "{{.ANSIBLE_DIR}}"
cmd: ansible kubernetes -i {{.ANSIBLE_INVENTORY_DIR}}/hosts.yaml -a '/usr/bin/systemctl poweroff' --become
env:
ANSIBLE_CONFIG: "{{.ANSIBLE_DIR}}/ansible.cfg"
-4
View File
@@ -14,16 +14,12 @@ tasks:
vars:
DEPS: >-
age
ansible
cilium-cli
cloudflared
direnv
fluxcd/tap/flux
go-task/tap/go-task
helm
kubernetes-cli
kustomize
python
sops
stern
yq
+1 -1
View File
@@ -20,7 +20,7 @@ tasks:
msg: |
Age key file is not found. Did you forget to create it?
vars:
SOPS_AGE_KEY_FILE: ~/.config/sops/age/keys.txt
SOPS_AGE_KEY_FILE: "{{.ROOT_DIR}}/age.key"
reconcile:
desc: Force update Flux to pull in changes from your Git repository