Add files via upload

This commit is contained in:
kneutron 2022-04-27 13:07:00 -05:00 committed by GitHub
parent ee2fc3ad83
commit 9372ce5a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#!/bin/bash5
# Paste a vertical list of servers separated by newline
# ^ pass them as comma-separated server(s) to ansible; reboot and wait up to 10 min
echo "Paste vertical list of servers / IP addresses; Enter EOF at the end of server list to begin processing"
buildstr=""
while read inline; do
[ "$inline" = "EOF" ] && break;
fstchr=${inline:0}
if [[ $fstchr =~ ^[0-9] ]] && [ $(echo $inline |awk '{sum+=gsub(/\./,"")}END{print sum}') -eq 3 ]; then
# 1st char=number and contains 3 dots, more than likely an IPV4 addr
buildstr="$buildstr$inline,"
else
hnonly=${inline%%.*} # strip evyting after first dot, dont need FQDN
hnonly=${hnonly,,} # and lowercase it
buildstr="$buildstr$hnonly,"
fi
done
buildstr=$(echo ${buildstr%,}) # omit trailing comma
servers=$buildstr
echo "$buildstr"
ansible-playbook reboot-and-wait.yml --become -e "target=$servers"

12
ans-reboot-server.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# pass comma-separated server(s) as arg; reboot and wait up to 10 min
if [ "$1" = "" ]; then
echo "Provide at least one target server as parameter"
exit 404;
else
servers=${@%,} # omit trailing comma
echo "$servers"
ansible-playbook reboot-and-wait.yml --become -e "target=$servers"
fi

15
reboot-and-wait.yml Normal file
View File

@ -0,0 +1,15 @@
---
- hosts: '{{target}}'
tasks:
- name: reboot and wait
become: yes
reboot:
reboot_timeout: 600
- - name: check uptime
register: uptimeoutput
command: "uptime"
- debug:
var: uptimeoutput.stdout_lines