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/CAF8BbLY-1O%2Bv6ZjVDeGJLdHvW93nrWN_YRDFSx-Ctw%3D97g30GQ%40mail.gmail.com.
