forsan_102218
Nov 06, 2018Nimbostratus
Ansible bigip_device_facts - Filter Output
Hi,
I'm new to ansible and have installed ansible version 2.7 and I'm trying to understand how I can filter the output from the new bigip_device_facts module as bigip_facts are depreciated.
I have checked the devcentral post for the old bigip_facts on https://devcentral.f5.com/questions/ansible-filter-output-48375
But the output from the bigip_device_facts is not the same as bigip_facts.
The new one looks like following:
changed: [172.16.223.128 -> localhost] => {
"changed": true,
"invocation": {
"module_args": {
"auth_provider": null,
"gather_subset": [
"vlans"
],
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"server": "172.16.223.128",
"server_port": 443,
"transport": null,
"user": "admin",
"validate_certs": false
}
},
"vlans": [
{
"auto_lasthop": "default",
"cmp_hash_algorithm": "default",
"failsafe_action": "failover-restart-tm",
"failsafe_enabled": "no",
"failsafe_timeout": 90,
"full_path": "/Common/HA",
"if_index": 160,
"interfaces": [
{
"full_path": "1.3",
"name": "1.3",
"tagged": "no"
}
],
"learning_mode": "enable-forward",
"mtu": 1500,
"name": "HA",
"sflow_poll_interval": 0,
"sflow_poll_interval_global": "yes",
"sflow_sampling_rate": 0,
"sflow_sampling_rate_global": "yes",
"source_check_enabled": "disabled",
"tag": 4092,
"true_mac_address": "00:0c:29:e0:10:eb"
}
]
}
Compared to the old:
"ansible_facts": {
"vlan": {
"/Common/VLAN_10": {
How can I use the debug msg to fileter and print values like vlan id (tag in this case).
Br Andréas
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 }}"