#!/bin/bash CLUSTER_OPS="$HOME/clustered-fucks" show_menu() { clear echo "╔═══════════════════════════════════════════════════════════════╗" echo "║ CLUSTER CONTROL - Ansible Menu ║" echo "╠═══════════════════════════════════════════════════════════════╣" echo "║ [1] Ping All - Test connectivity ║" echo "║ [2] Check Status - Disk/memory/containers ║" echo "║ [3] Update All - apt upgrade docker hosts ║" echo "║ [4] Docker Prune - Clean unused resources ║" echo "║ [5] Restart Utils - Restart utils stack everywhere ║" echo "║ ║" echo "║ [A] Ad-hoc Command - Run custom command ║" echo "║ [I] Inventory - Show host list ║" echo "║ [S] SSH Manager - Launch tmux session ║" echo "║ ║" echo "║ [Q] Quit ║" echo "╚═══════════════════════════════════════════════════════════════╝" echo "" } cd "$CLUSTER_OPS" while true; do show_menu read -p "Choice: " choice case ${choice^^} in 1) ansible all -m ping; read -p "Press Enter..." ;; 2) ansible-playbook playbooks/check-status.yml; read -p "Press Enter..." ;; 3) ansible-playbook playbooks/update-all.yml; read -p "Press Enter..." ;; 4) ansible-playbook playbooks/docker-prune.yml; read -p "Press Enter..." ;; 5) ansible-playbook playbooks/restart-utils.yml; read -p "Press Enter..." ;; A) read -p "Target [all]: " target target=${target:-all} read -p "Command: " cmd [ -n "$cmd" ] && ansible $target -m shell -a "$cmd" read -p "Press Enter..." ;; I) ansible-inventory --graph; read -p "Press Enter..." ;; S) ~/scripts/ssh-manager.sh; exit 0 ;; Q) exit 0 ;; esac done