If you have multiple VMs, you might want to look into a program called pdsh. It can be used to run commands (via ssh) on multiple remote machines (real or virtual) in parallel.
It was written for use in HPC clusters, but it's a useful sysadmin tool for working with any group of linux/unix machines.
https://computing.llnl.gov/linux/pdsh.html
e.g. if I have a bunch of machines defined with the attribute "compute" (nova-compute nodes in an openstack deployment), I can run the following command to find out how many nodes have 16 or more cores free (out of 24 cores per node) and are this capable of running an xxlarge 16-core VM:
# pdsh -g compute "ps hwwu -Ckvm | sed -e 's/.*-smp //' -e 's/,.*//' |
awk '{VMS += 1 ; CPUS += \$1} END {print VMS, CPUS, 24-CPUS}'" | \
awk '$4 > 15 {print}' | sort -k4 -n
comp17: 6 8 16
comp19: 6 8 16
comp23: 6 8 16
comp26: 7 8 16
comp51: 7 8 16
comp56: 6 8 16
comp71: 7 8 16
comp78: 7 8 16
comp81: 6 8 16
comp11: 6 7 17
comp47: 6 7 17
comp79: 6 7 17
comp09: 5 6 18
comp29: 5 5 19
comp27: 4 4 20
(real usage output, hostnames edited for anonymity)
The command inside the double-quotes is executed on the remote machines (shell quoting rules apply, hence the \$1 in the first awk), and the remainder (the second awk and the sort) is executed on the local machine.
yum -y install bash,chsh -s /bin/bash, profit?/bin/sh -c "command > redirect"