24-Aug-2022 08:11
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.
Solved! Go to Solution.
31-Aug-2022 05:55
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.
25-Aug-2022 11:49
Hi @e0013192 - would any of the solutions offered on https://community.f5.com/t5/technical-forum/list-pools-by-name/td-p/194471 help?
25-Aug-2022 12:19
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
25-Aug-2022 13:03
Can you show me a tmsh show and list of the policy object?
25-Aug-2022 13:23
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 }
}
}
}
}
31-Aug-2022 05:55
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.
31-Aug-2022 13:02 - edited 31-Aug-2022 13:02
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.
02-Sep-2022 08:28
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