cancel
Showing results for 
Search instead for 
Did you mean: 

Bigip_device_info for ltm-policies doesn't have an action of forward

e0013192
Altostratus
Altostratus

I'm trying to figure out how to get a list of the pools we are forwarding to in our policies.  I don't see the action in the bigip_device_info for forward.  I've tried to use the REST API with the Ansible url command but then I don't know how to parse the output so I just get the pool names.  I need the pool names that the policy is forwarding to so I can check the status of the pools and the members.  Any suggestion wouls be greatly appreciated.

1 ACCEPTED SOLUTION

There you go!

So you can use the bigip command module in our ansible to pass the tmsh parameters in and grep for those 2 pools.

https://clouddocs.f5.com/products/orchestration/ansible/devel/f5_bigip/modules_2_0/bigip_command_mod...

 

View solution in original post

7 REPLIES 7

Leslie_Hubertus
Community Manager
Community Manager

 Hi @e0013192 - would any of the solutions offered on https://community.f5.com/t5/technical-forum/list-pools-by-name/td-p/194471 help?

e0013192
Altostratus
Altostratus

Thank you for your reply but I'm not sure those solutions will help.  I'm pulling the bigip_device_info based on a virtual-server then I'm parsing the policy name and getting the facts for the policy also using the bigip_device_info.  The issue is that subset of the ltm-policy fact from the bigip_device_info module doesn't provide a way to get the pools we are forwarding to.  i have to be able to find the pools associated with the access policy without know what the pool name are which is why I'm using the facts.  

This is what I'm doing.

   

 

    - name: json_query - VIP address
      set_fact:
        vip_result: "{{ bigip_facts.virtual_servers|default({}) | json_query(jmesquery) }}"
      vars:
        jmesquery: "[?destination=='/Common/{{ item.destination_address }}:{{ item.destination_port }}'].{virtual_name: name, destination_address: destination_address, destination_port: destination_port, snat_pool: snat_pool, default_pool: default_pool, persistence_profile: persistence_profile, profiles: profiles[*].{context: context,name: name}, policy_name: policies[*], irules: irules[*], virtual_state: availability_status virtual_enabled: enabled}"
      loop: "{{ vip }}"

    - name: json_query - Policy
      set_fact:
        policy_result: "{{ vip_result[0].policy_name }}"
      loop: "{{ vip }}"

    - name: json_query - Policy Details
      set_fact:
        policy_details: "{{ bigip_facts.ltm_policies|default({}) | json_query(jmesquery) }}"
      vars:
        jmesquery: "[?full_path=='{{policy_result}}']"
      when: vip_result[0].policy_name is defined

 

AubreyKingF5
Community Manager
Community Manager

Can you show me a tmsh show and list of the policy object?

ltm policy test.local_policy {
    controls { forwarding }
    draft-copy Drafts/test.local_policy
    last-modified 2022-06-21:11:06:48
    requires { http }
    rules {
        test.local-010 {
            actions {
                0 {
                    forward
                    select
                    pool A-443_pool
                }
            }
            conditions {
                0 {
                    http-uri
                    path
                    starts-with
                    values { /test010 }
                }
            }
        }
        test.local-020 {
            actions {
                0 {
                    forward
                    select
                    pool B-443_pool
                }
            }
            conditions {
                0 {
                    http-uri
                    path
                    starts-with
                    values { /test020 }
                }
            }
        }
    }

There you go!

So you can use the bigip command module in our ansible to pass the tmsh parameters in and grep for those 2 pools.

https://clouddocs.f5.com/products/orchestration/ansible/devel/f5_bigip/modules_2_0/bigip_command_mod...

 

e0013192
Altostratus
Altostratus

I'm familiar with the command module but my issue there is how to parse the stdout so that I can further use the results in other tasks.   I need the pool names to complete the decommisioning of the pools and the nodes.

I see the issue. So you want to keep that data. This is your friend:

https://docs.ansible.com/ansible/latest/reference_appendices/logging.html