Forum Discussion

BabaG's avatar
BabaG
Icon for Nimbostratus rankNimbostratus
Jun 27, 2019

Checking Image versions on multiple F5 Devices

Dear all,

 

I am wondering how I can check image versions without login into all devices?

We are planing an upgrade and the task is to check if there consistent images on all ?

 

Thanks in advance

6 Replies

  • You could write a script that uses the REST API:

     

    curl -X GET -u admin:admin -k "https://10.0.0.1/mgmt/tm/sys/version"

     

     

  • BabaG's avatar
    BabaG
    Icon for Nimbostratus rankNimbostratus

    Many thanks Lee,

     

    I will have to for a crash course on REST, I presume

    Do you know or have any materials on REST, to narrow the search down ?

     

    I was thinking if there is anything within F5 or its views that can be query and produce a reports

     

    Regards

  • Hi BabaG,

    If you have a jump server, the job is easier.

    Requirements:

    1. Jump Server having reachability to all your remote F5 servers.
    2. Have the passwordless login set up if not done already. You can refer internet on how to have passwordless login from a particular account. Or worst case, have a sshpass method used.
    3. A bash script.
    4. A list of F5 servers.

    Create a simple bash script like below in your Jump server, lets say we name it version-script.

    Paste the below code in the version-script. For now we have our scripts in /var/tmp/.

    Jumpserver# vi version-script

     

    #!/usr/bin/bash
    version="$(cat /VERSION | grep Version)"
    echo $HOSTNAME,$version

     

    Have a list of servers added in the file - /var/tmp/serverlist.txt.

    Now comes the execution part for multiple devices, I've put root user assuming you have the root's key already exchanged for passwordless login. You can change accordingly.

    Create the executable script, named as run-script. Paste the below code in the run-script.

    Jumpserver# vi run-script

     

    echo "HOSTNAME,Version" > /var/tmp/F5-version-report.csv
    for i in `cat /var/tmp/serverlist.txt`;
    do
    ssh root@$i "-o StrictHostKeyChecking=no" "bash -s" < ./version-script  >> /var/tmp/F5-version-report.csv
    done

     

    All set and done, Just have the script executed (run-script).

     

    bash run-script

     

    Your outputs will be saved in /var/tmp/ location with the file named F5-version-report.csv. The good part is, its in csv format, so you can simply open in the excel sheet and use it for audit purpose.

    • BabaG's avatar
      BabaG
      Icon for Nimbostratus rankNimbostratus

      Many thanks for the solutions, I did not have access to jumpServer since, reason I haven't test the solutions or reply for the confirmation

       

      I have now able to test and I can confirm it works as you have shown

       

      Many thanks once again and appreciated greatly!!

       

      Regards

       

      Baba

  • BabaG's avatar
    BabaG
    Icon for Nimbostratus rankNimbostratus

    Hello again,

    Is there anyway I can just input password once and carry it to the end instead of entering password on every devices?

     

    Regards

    • Hi  ,

      I had this explained in this step,

      Have the passwordless login set up if not done already. You can refer internet on how to have passwordless login from a particular account. Or worst case, have a sshpass method used.

      You can google on how to use sshpass method. Its your call to put explictly or by using in a file.

      sshpass -p 'secret-password'

       

      echo "HOSTNAME,Version" > /var/tmp/F5-version-report.csv
      for i in `cat /var/tmp/serverlist.txt`;
      do
      sshpass -p 'secret-password' ssh root@$i "-o StrictHostKeyChecking=no" "bash -s" < ./version-script  >> /var/tmp/F5-version-report.csv
      done

       

      or write your password in a file, make it readable by the user (share proper privileges)

      sshpass -f secretfile 

       

      echo "HOSTNAME,Version" > /var/tmp/F5-version-report.csv
      for i in `cat /var/tmp/serverlist.txt`;
      do
      sshpass -f secretfile root@$i "-o StrictHostKeyChecking=no" "bash -s" < ./version-script  >> /var/tmp/F5-version-report.csv
      done

       

      Hope this helps.

      Mark the answer as solution provided if you find it as your solution 🙂