Reputation: 15
I have the following ansible playbook, to gather facts from NAT Rules. The playbook works as expected:
- name: Get Facts from NAT Rules
hosts: panorama
connection: local
gather_facts: False
vars:
ansible_python_interpreter: /usr/bin/python3
collections:
- paloaltonetworks.panos
tasks:
- name: Get a list of all NAT rules
panos_nat_rule_facts:
provider: '{{ provider }}'
listing: True
device_group: PA-02
rulebase: post-rulebase
register: nat_rules
- debug:
msg: '{{ nat_rules.listing }}'
The output of the playbook, provides the facts from the NAT Rules, however, I would interested in getting only the value of the snat_static_address and nothing else:
ok: [10.1.10.100] => {
"msg": [
{
"description": null,
"destination_dynamic_translated_address": null,
"destination_dynamic_translated_distribution": null,
"destination_dynamic_translated_port": null,
"destination_ip": [
"any"
],
"destination_zone": [
"wan"
],
"disabled": null,
"dnat_address": null,
"dnat_port": null,
"group_tag": null,
"ha_binding": null,
"nat_type": null,
"negate_target": false,
"rule_name": "NAT_01",
"service": "any",
"snat_address_type": null,
"snat_bidirectional": true,
"snat_dynamic_address": null,
"snat_interface": null,
"snat_interface_address": null,
"snat_static_address": "74.120.99.147",
"snat_type": "static-ip",
"source_ip": [
"10.1.10.10"
],
"source_translation_fallback_interface": null,
"source_translation_fallback_ip_address": null,
"source_translation_fallback_ip_type": null,
"source_translation_fallback_translated_addresses": null,
"source_translation_fallback_type": null,
"source_zone": [
"lan"
],
"tag_val": null,
"target": null,
"to_interface": null,
"uuid": null
}
]
}
I would like to filter this output to retrieve the value of: snat_static_address. How can I achieve this?
Upvotes: 1
Views: 225
Reputation: 4400
You could reference the value with the following syntax
- debug:
msg: '{{ nat_rules.listing | map(attribute="snat_static_address") }}'
Upvotes: 1