*i'm getting below error *
*fatal: [localhost]: FAILED! => {"msg": "unable to locate parse_xml
template: spec"}*
*here is the xml data :*
<?xml version="1.0" encoding="UTF-8"?>
<vpn_connection id="vpn-008611c2097786810">
<customer_gateway_id>cgw-0d4ee490353c847a6</customer_gateway_id>
<vpn_gateway_id>vgw-02843421cc2ba3987</vpn_gateway_id>
<vpn_connection_type>ipsec.1</vpn_connection_type>
<vpn_connection_attributes>NoBGPVPNConnection</vpn_connection_attributes>
<ipsec_tunnel>
<customer_gateway>
<tunnel_outside_address>
<ip_address>131.226.223.241</ip_address>
</tunnel_outside_address>
<tunnel_inside_address>
<ip_address>169.254.77.10</ip_address>
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
</customer_gateway>
<vpn_gateway>
<tunnel_outside_address>
<ip_address>52.71.191.154</ip_address>
</tunnel_outside_address>
<tunnel_inside_address>
<ip_address>169.254.77.9</ip_address>
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
</vpn_gateway>
<ike>
<authentication_protocol>sha1</authentication_protocol>
<encryption_protocol>aes-128-cbc</encryption_protocol>
<lifetime>28800</lifetime>
<perfect_forward_secrecy>group2</perfect_forward_secrecy>
<mode>main</mode>
<pre_shared_key>1i5R5wqKDUx2HGvlTAIcbupHPpyns.4H</pre_shared_key>
</ike>
<ipsec>
<protocol>esp</protocol>
<authentication_protocol>hmac-sha1-96</authentication_protocol>
<encryption_protocol>aes-128-cbc</encryption_protocol>
<lifetime>3600</lifetime>
<perfect_forward_secrecy>group2</perfect_forward_secrecy>
<mode>tunnel</mode>
<clear_df_bit>true</clear_df_bit>
<fragmentation_before_encryption>true</fragmentation_before_encryption>
<tcp_mss_adjustment>1379</tcp_mss_adjustment>
<dead_peer_detection>
<interval>10</interval>
<retries>3</retries>
</dead_peer_detection>
</ipsec>
</ipsec_tunnel>
<ipsec_tunnel>
<customer_gateway>
<tunnel_outside_address>
<ip_address>131.226.223.241</ip_address>
</tunnel_outside_address>
<tunnel_inside_address>
<ip_address>169.254.64.30</ip_address>
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
</customer_gateway>
<vpn_gateway>
<tunnel_outside_address>
<ip_address>54.88.91.92</ip_address>
</tunnel_outside_address>
<tunnel_inside_address>
<ip_address>169.254.64.29</ip_address>
<network_mask>255.255.255.252</network_mask>
<network_cidr>30</network_cidr>
</tunnel_inside_address>
</vpn_gateway>
<ike>
<authentication_protocol>sha1</authentication_protocol>
<encryption_protocol>aes-128-cbc</encryption_protocol>
<lifetime>28800</lifetime>
<perfect_forward_secrecy>group2</perfect_forward_secrecy>
<mode>main</mode>
<pre_shared_key>NH_yZv8oTv2FkCVS5OKbydIkMEItKWOO</pre_shared_key>
</ike>
<ipsec>
<protocol>esp</protocol>
<authentication_protocol>hmac-sha1-96</authentication_protocol>
<encryption_protocol>aes-128-cbc</encryption_protocol>
<lifetime>3600</lifetime>
<perfect_forward_secrecy>group2</perfect_forward_secrecy>
<mode>tunnel</mode>
<clear_df_bit>true</clear_df_bit>
<fragmentation_before_encryption>true</fragmentation_before_encryption>
<tcp_mss_adjustment>1379</tcp_mss_adjustment>
<dead_peer_detection>
<interval>10</interval>
<retries>3</retries>
</dead_peer_detection>
</ipsec>
</ipsec_tunnel>
</vpn_connection>
On Friday, July 8, 2022 at 12:48:26 PM UTC+5:30 [email protected] wrote:
> Perhaps, if you provide a clean piece of xml.
>
>
> On Fri, 8 Jul 2022 at 08:37, maulik patel <[email protected]> wrote:
>
>> anyone here to help me out with this please ? thanks...
>>
>> On Thursday, July 7, 2022 at 6:57:27 PM UTC+5:30 maulik patel wrote:
>>
>>> hi ,
>>>
>>> I was trying to parse a XML response to JSON using parse_xml from an AWS
>>> VPN output, but I'm getting the below error.
>>> I am able to parse data with
>>> *"vpn_conn_facts.vpn_connections[0].customer_gateway_configuration"*
>>> but, it is when I apply the filter parse_xml, that the error arise.
>>>
>>> *-> Error:*
>>> *fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type
>>> error occurred on ({{
>>> vpn_conn_facts.vpn_connections[0].customer_gateway_configuration |
>>> parse_xml('aws_vpn_parser.yaml') }}): 'NoneType' object is not
>>> subscriptable"}*
>>>
>>> *-> playbook:*
>>> ---
>>> - hosts: '{{ PALO_HOST | default("localhost") }}'
>>> connection: local
>>> gather_facts: true
>>>
>>> collections:
>>> - paloaltonetworks.panos
>>>
>>> tasks:
>>> - name: load var
>>> include_vars: provider.yaml
>>>
>>> - name: load aws var
>>> include_vars: /etc/ansible/aws/vpn_facts.yaml
>>>
>>> - name: load variable dir
>>> include_vars:
>>> dir: /etc/ansible/aws/vars/
>>> - name: aws_vpn connection info
>>> ec2_vpc_vpn_info:
>>> vpn_connection_ids: '{{ vpn_id }}'
>>> region: "{{ region }}"
>>> aws_access_key: "{{ aws_access_key }}"
>>> aws_secret_key: "{{ aws_secret_key }}"
>>> register: vpn_conn_facts
>>>
>>> - name: set_fact
>>> set_fact:
>>> parsed: "{{ *
>>> vpn_conn_facts.vpn_connections[0].customer_gateway_configuration
>>> | parse_xml('aws_vpn_parser.yaml') }}" *
>>>
>>> - debug: msg: '{{ parsed }}'
>>>
>>>
>>>
>>> -> output of
>>> "*vpn_conn_facts.vpn_connections[0].customer_gateway_configuration"
>>> :*
>>>
>>> *"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection
>>> id=\"vpn-04ce6c395e9883880\">\n
>>> <customer_gateway_id>cgw-03337136da58e954a</customer_gateway_id>\n
>>> <vpn_gateway_id>vgw-007ac15c18a444e89</vpn_gateway_id>\n
>>> <vpn_connection_type>ipsec.1</vpn_connection_type>\n
>>>
>>> <vpn_connection_attributes>NoBGPVPNConnection</vpn_connection_attributes>\n
>>> <ipsec_tunnel>\n <customer_gateway>\n <tunnel_outside_address>\n
>>> <ip_address>131.226.223.241</ip_address>\n
>>> </tunnel_outside_address>\n <tunnel_inside_address>\n
>>> <ip_address>169.254.254.58</ip_address>\n
>>> <network_mask>255.255.255.252</network_mask>\n
>>> <network_cidr>30</network_cidr>\n </tunnel_inside_address>\n
>>> </customer_gateway>\n <vpn_gateway>\n <tunnel_outside_address>\n
>>> <ip_address>34.232.238.139</ip_address>\n
>>> </tunnel_outside_address>\n <tunnel_inside_address>\n
>>> <ip_address>169.254.254.57</ip_address>\n
>>> <network_mask>255.255.255.252</network_mask>\n
>>> <network_cidr>30</network_cidr>\n </tunnel_inside_address>\n
>>> </vpn_gateway>\n <ike>\n
>>> <authentication_protocol>sha1</authentication_protocol>\n
>>> <encryption_protocol>aes-128-cbc</encryption_protocol>\n
>>> <lifetime>28800</lifetime>\n
>>> <perfect_forward_secrecy>group2</perfect_forward_secrecy>\n
>>> <mode>main</mode>\n
>>> <pre_shared_key>JXzQgDDNG944e0nnh4w.6bgqFhAQIA.W</pre_shared_key>\n
>>> </ike>\n <ipsec>\n <protocol>esp</protocol>\n
>>> <authentication_protocol>hmac-sha1-96</authentication_protocol>\n
>>> <encryption_protocol>aes-128-cbc</encryption_protocol>\n
>>> <lifetime>3600</lifetime>\n
>>> <perfect_forward_secrecy>group2</perfect_forward_secrecy>\n
>>> <mode>tunnel</mode>\n <clear_df_bit>true</clear_df_bit>\n
>>> <fragmentation_before_encryption>true</fragmentation_before_encryption>\n
>>> <tcp_mss_adjustment>1379</tcp_mss_adjustment>\n
>>> <dead_peer_detection>\n <interval>10</interval>\n
>>> <retries>3</retries>\n </dead_peer_detection>\n </ipsec>\n
>>> </ipsec_tunnel>\n <ipsec_tunnel>\n <customer_gateway>\n
>>> <tunnel_outside_address>\n
>>> <ip_address>131.226.223.241</ip_address>\n
>>> </tunnel_outside_address>\n <tunnel_inside_address>\n
>>> <ip_address>169.254.207.46</ip_address>\n
>>> <network_mask>255.255.255.252</network_mask>\n
>>> <network_cidr>30</network_cidr>\n </tunnel_inside_address>\n
>>> </customer_gateway>\n <vpn_gateway>\n <tunnel_outside_address>\n
>>> <ip_address>54.225.7.92</ip_address>\n
>>> </tunnel_outside_address>\n <tunnel_inside_address>\n
>>> <ip_address>169.254.207.45</ip_address>\n
>>> <network_mask>255.255.255.252</network_mask>\n
>>> <network_cidr>30</network_cidr>\n </tunnel_inside_address>\n
>>> </vpn_gateway>\n <ike>\n
>>> <authentication_protocol>sha1</authentication_protocol>\n
>>> <encryption_protocol>aes-128-cbc</encryption_protocol>\n
>>> <lifetime>28800</lifetime>\n
>>> <perfect_forward_secrecy>group2</perfect_forward_secrecy>\n
>>> <mode>main</mode>\n
>>> <pre_shared_key>RDt7vieaxRkjUwaCJ8M8Lo.Qztdhhfdq</pre_shared_key>\n
>>> </ike>\n <ipsec>\n <protocol>esp</protocol>\n
>>> <authentication_protocol>hmac-sha1-96</authentication_protocol>\n
>>> <encryption_protocol>aes-128-cbc</encryption_protocol>\n
>>> <lifetime>3600</lifetime>\n
>>> <perfect_forward_secrecy>group2</perfect_forward_secrecy>\n
>>> <mode>tunnel</mode>\n <clear_df_bit>true</clear_df_bit>\n
>>> <fragmentation_before_encryption>true</fragmentation_before_encryption>\n
>>> <tcp_mss_adjustment>1379</tcp_mss_adjustment>\n
>>> <dead_peer_detection>\n <interval>10</interval>\n
>>> <retries>3</retries>\n </dead_peer_detection>\n </ipsec>\n
>>> </ipsec_tunnel>\n</vpn_connection>"*
>>>
>>>
>>> i'm suspecting that there is something wrong with xml o/p that we get it
>>> above, but this is directly coming from aws customer gateway ..
>>>
>>> any suggestion would be appreciated...
>>>
>>> thanks...!!
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/dab2b663-0976-4b78-914e-c48dc4b95f2cn%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/dab2b663-0976-4b78-914e-c48dc4b95f2cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Sent from Gmail Mobile
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/88ee4054-21e5-4975-b27a-b4ddc3235db4n%40googlegroups.com.