Forum Discussion

Thiyagu's avatar
Thiyagu
Icon for Cirrus rankCirrus
Mar 17, 2023

Need help with Ansible to ping multiple VIP IPs

Hello All,

I'm working on Ansible script to ping the the F5 VIP IPs. Could you please share if anybody has worked on similar script for pinging LB VIPs?

Thanks,

Thiyagu

1 Reply

  • Hi Thiyagu, I asked chatGPT about that (I don't do a lot with ansible personally) and got this back, perhaps this will get you started:

     

    ---
    - name: Ping all virtual servers on F5 BIG-IP
      hosts: bigip
      gather_facts: no
    
      tasks:
        - name: Get virtual server addrs
          bigip_device_info:
            gather_subset:
              - virtual-addresses
          register: vs_addrs
    
        - name: Ping virtual servers
          ping:
          with_items: "{{ vs_addr['virtual_address'] }}"
          when: item['enabled'] == True
          loop_control:
            label: "{{ item['address'] }}"
    

     

     

    You might need to tweak/tune (as I did a little to update, the chatGPT provide _facts module has been deprecated in favor of the _info one, and you don't need all the virtual-server data, just the addresses, so I swapped that out too.