23 lines
591 B
Bash
23 lines
591 B
Bash
|
#!/bin/bash
|
||
|
CMD=$1
|
||
|
|
||
|
echo -e "You are about to run \e[1;32m$CMD\e[0m on all hosts."
|
||
|
|
||
|
run () {
|
||
|
if grep -q "sudo" <<< "$CMD"; then
|
||
|
echo "sudo command detected. Attempting to elevate permissions"
|
||
|
parallel-ssh -A -i -x '-tt' -t 0 -h pssh_hosts -l ansible "echo 'ansible' | $CMD && history -c"
|
||
|
else
|
||
|
parallel-ssh -A -i -x '-tt' -h pssh_hosts -l ansible "$CMD && history -c"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
while true; do
|
||
|
read -p "Are you sure? (y/n): " yn
|
||
|
case $yn in
|
||
|
[Yy]* ) run; break;;
|
||
|
[Nn]* ) exit;;
|
||
|
* ) echo "Please answer yes or no.";;
|
||
|
esac
|
||
|
done
|