An alternate solution for something more dynamic... no static config in the fabfile, using bash.
mfab() {
hosts=()
while [ "$#" != 0 ]; do
if [ "$1" = -- ]; then
shift
break
fi
hosts+=("$1")
shift
done
list=$(echo "${hosts[@]}" | tr ' ' ',')
fab -H "$list" "$@"
}
Here's a way to make it do a dry run... run this before your tests:
fab() { echo fab "$@"; }
example 1: arbitrary size list using shell expansions/globbinb/whatever you want to use
mfab node{A..D}{01..05} -- example_command
will run a command like:
fab -H nodeA01,nodeA02,nodeA03,nodeA04,nodeA05,nodeB01,nodeB02,nodeB03,nodeB04,nodeB05,nodeC01,nodeC02,nodeC03,nodeC04,nodeC05,nodeD01,nodeD02,nodeD03,nodeD04,nodeD05 example_command
example 2: I just deployed 7 new machines and every 2nd one is broken and I want to run a command to check/fix it.
mfab node{100..106..2} -- example_command
will run a command like:
fab -H node100,node102,node104,node106 example_command
example 3: more options including --
used by fabric itself:
mfab node{01..10} -- -P -- uname -a