The script assumes:
a) you have something like defined:
export maindev=maindev
export bkupdev=bkupdev
export mainstg=mainstg
export bkupstg=bkupstg
export mainprod=mainprod
export bkupprod=bkupprod
export alldev="maindev bkupdev"
export allstg="mainstg bkupstg"
# Expansion is not recursive, can't use alllow="alldev allstg" here.
export alllow="maindev bkupdev mainstg bkupstg"
where the identify definitions are needed for dereferencing later, and, in .ssh/config
Host maindev
HostName dev.example.com
User me_who_else
Host bkupdev
HostName dev-reserve.example.com
User me_who_else
Then on alldev uname -n
returns:
## On maindev: uname -n
dev.example.com maindev
## On bkupdev: uname -n
dev-reserve.example.com bkupdev
column -t
is helpful for cleaning up output.
on -n
will not append the host alias to each line of output.
on "host01 hostgroupB"
will drop the user into a shell on each host in sequence.