Forum Discussion

jleach_241920's avatar
jleach_241920
Icon for Nimbostratus rankNimbostratus
Nov 04, 2016

Running tmsh commands on multiple devices at once

Hey DevCentral,

 

I was hoping BIG-IQ CM would make this a little easier to do but that isn't the case. I need to run the same tmsh commands on multiple devices at once, instead of taking hours to do them one by one. This is something I've never attempted, as it is a new concept for me.

 

Does anyone have any ideas as to how to do that?

 

  • Prerequisite: You will need a box that can ssh to all of your devices. "Pivot box" or "Jump box"

    --Using CLI via F5 box or *Nix box

    Shown below on a Version 9 box: Show me: hostname and kernel version and BIGIP version

    && - Will execute the command whether the previous command completed successfully.

    while read HOST ; do echo "" | ssh $HOST "uname -a && date && echo -en '\n' && b version show | head -6 | sed 's/Final*//'" ; done < f5hosts.txt

    f5hosts.txt --a list of all of the boxes you want to run tmsh commands, by hostname or IP

    in between the quotes you list out the tmos commands. ie. "tmostcommand && tmostcommand && tmoscommand"

    while read HOST ; do echo "" | ssh $HOST "tmostcommand && tmostcommand && tmoscommand" ; done < f5hosts.txt

    Example:

    while read HOST ; do echo "" | ssh $HOST "tmsh show ltm persistence persist-records && tmsh show ltm nat all && show sys hardware  " ; done < f5hosts.txt

    If you prefer you can pipe everything out to a file.

    while read HOST ; do echo "" | ssh $HOST "tmsh show ltm persistence persist-records && tmsh show ltm nat all && show sys hardware  " ; done < f5hosts.txt
    > output.txt