diff --git a/files/prox-login-check.sh b/files/prox-login-check.sh new file mode 100644 index 0000000..35f9b3f --- /dev/null +++ b/files/prox-login-check.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# space-delimited list of services to check +servicelist=(corosync) + +echo -e "\n" +echo -e "$(tput smul)Service Check$(tput sgr0)\n" + +for service in ${servicelist[@]}; do + echo -e "${service}:" + systemctl status $service | grep Active: | tr -s [:blank:] + echo +done +echo +#Sections: Rows: +# Cluster information 4 +# Quorum information 6 (5 necessary) +# Votequorum information 5 +# Membership information 4 + +colover=30 + +function uplines { + [ -z $1 ] && return + lines=$1 + while [ $lines -gt 0 ]; do + tput cuu1 + let lines=lines-1 + done +} + +statcmd='pvecm status' +currentrow='Cluster information' +linec=0 +while read -r line; do + if [[ "$currentrow" == "Cluster information" ]]; then + if [[ "$line" == "Quorum information" ]]; then + currentrow="$line" + linec=0 + continue + fi + echo $line + fi + if [[ "$currentrow" == "Quorum information" ]]; then + if [[ "$line" == "Votequorum information" ]]; then + currentrow="$line" + linec=0 + echo $line + continue + fi + if [[ "$line" == "Date"* ]]; then + continue + fi + if [ $linec -eq 0 ]; then + uplines 7; tput cuf $colover; echo -e "$currentrow" + fi + tput cuf $colover + echo $line + let linec=linec+1 + fi + if [[ "$currentrow" == "Votequorum information" ]]; then + if [[ "$line" == "Membership information" ]]; then + currentrow="$line" + linec=0 + continue + fi + echo $line + fi + if [[ "$currentrow" == "Membership information" ]]; then + if [ $linec -eq 0 ]; then + uplines 8; tput cuf $colover; echo -e "$currentrow" + fi + tput cuf $colover + echo $line + let linec=linec+1 + fi +done <<< $($statcmd) +echo + +echo +echo "$(tput sitm)run the $(basename $0) script in $(dirname $0) to get these stats again$(tput sgr0)" +echo diff --git a/playbooks/prox-maint.yaml b/playbooks/prox-maint.yaml new file mode 100644 index 0000000..f250c6c --- /dev/null +++ b/playbooks/prox-maint.yaml @@ -0,0 +1,21 @@ +--- +- name: Proxmox maintenance + hosts: proxmox + tasks: + - name: Ensuring login-check is present + ansible.builtin.copy: + src: /home/michael/ansible/files/prox-login-check.sh + dest: /root/prox-login-check + mode: "0755" + + - name: Ensuring login-check is configured to run on login + ansible.builtin.lineinfile: + state: present + insertafter: "EOF" + line: "/root/prox-login-check" + path: /root/.profile + + - name: Download vim config from aperture + ansible.builtin.get_url: + dest: ~/.vimrc + url: https://aperture.dismyserver.net/.vimrc