mirror of
https://github.com/kneutron/ansitest.git
synced 2025-01-16 04:42:55 +08:00
Add files via upload
This commit is contained in:
parent
ee2fc3ad83
commit
9372ce5a85
26
ans-reboot-server-copypasta.sh
Normal file
26
ans-reboot-server-copypasta.sh
Normal 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
12
ans-reboot-server.sh
Normal 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
15
reboot-and-wait.yml
Normal 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
|
Loading…
x
Reference in New Issue
Block a user