Forum Discussion
Ansible bigip_device_facts - Filter Output
- Nov 08, 2018
The result from bigip_device_facts contains a list of dictionaries. It can be processed in a number of ways depending on the output you want, but here's a simple example how to print the output with debug:
- bigip_device_facts: provider: "{{ provider_vars }}" gather_subset: - vlans register: gathered_facts - name: "Debug vlans" debug: msg: "VLAN {{ item.name }} has tag {{ item.tag }}" with_items: "{{ gathered_facts.vlans }}"
Hi,
It was my fault. I was using as variable the 'ltm-pool' option from gather_subset instead of the 'ltm_pool' from the output of the registered facts. It works as expected.
Thanks!
Hi all, I am having another issue obtaining filtered information from this module. With the given example, I can use the item.* for referencing the subfields under 'vlans'.
"bigip_device_facts": {
"changed": true,
"failed": false,
"vlans": [
{
"auto_lasthop": "default",
"cmp_hash_algorithm": "default",
"failsafe_action": "failover-restart-tm",
"failsafe_enabled": "no",
"failsafe_timeout": 90,
"full_path": "/Common/F5TEST",
"if_index": 96,
"learning_mode": "enable-forward",
"mtu": 1500,
"name": "F5TEST",
"sflow_poll_interval": 0,
"sflow_poll_interval_global": "yes",
"sflow_sampling_rate": 0,
"sflow_sampling_rate_global": "yes",
"source_check_enabled": "disabled",
"tag": 2015,
"true_mac_address": "00:11:22:33:44:55"
But, if I use the subset 'ltm-pools', there is another sublevel under members.
"bigip_device_facts": {
"changed": true,
"failed": false,
"ltm_pools": [
{
"allow_nat": "yes",
"allow_snat": "yes",
"client_ip_tos": "pass-through",
"client_link_qos": "pass-through",
"full_path": "/Common/mypool",
"ignore_persisted_weight": "no",
"lb_method": "round-robin",
"members": [
{
"address": "192.168.10.10",
"connection_limit": 0,
"dynamic_ratio": 1,
"ephemeral": "no",
"fqdn_autopopulate": "no",
"full_path": "/Common/myhost:8080",
"inherit_profile": "yes",
"logging": "no",
"monitors": [],
"name": "myhost:8080",
"partition": "Common",
"priority_group": 0,
"rate_limit": "no",
"ratio": 1,
"state": "disabled"
},
I want to extract only 'name' and 'state', but it remains in the previous level.
- name: "LTM_POOLS OUTPUT"
debug:
msg: "{{ item.members }} has name {{ item.name }} and state {{ item.state }}"
with_items: "{{ bigip_device_facts.ltm_pools }}"
when: item.full_path == "/Common/mypool"
This doesn't work. It remains at member level. How can I reference the sublevel of members? Thanks!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com