Skip to content

Instantly share code, notes, and snippets.

@dthvt
Created March 8, 2019 20:42
Show Gist options
  • Save dthvt/cdad42cdf3b99a2f9b056c6aaf2bb38e to your computer and use it in GitHub Desktop.
Save dthvt/cdad42cdf3b99a2f9b056c6aaf2bb38e to your computer and use it in GitHub Desktop.
parse_xml - parse_xml-aws-vpn-connection.yml
---
vars:
vpn_connection:
# General data
vpn_connection_id: "{{ item.vpn_connection_id.get('id') }}"
customer_gateway_id: "{{ item.customer_gateway_id }}"
vpn_gateway_id: "{{ item.vpn_gateway_id }}"
vpn_connection_type: "{{ item.vpn_connection_type }}"
# Tunnel 1, customer side
tunnel1_customer_gateway_outside_address: "{{ item.tunnel1_customer_gateway_outside_address }}"
tunnel1_customer_gateway_inside_address: "{{ item.tunnel1_customer_gateway_inside_address }}"
tunnel1_customer_gateway_inside_netmask: "{{ item.tunnel1_customer_gateway_inside_netmask }}"
tunnel1_customer_gateway_inside_cidr: "{{ item.tunnel1_customer_gateway_inside_cidr }}"
tunnel1_customer_gateway_bgp_asn: "{{ item.tunnel1_customer_gateway_bgp_asn }}"
tunnel1_customer_gateway_bgp_hold_time: "{{ item.tunnel1_customer_gateway_bgp_hold_time }}"
# Tunnel 1, AWS side
tunnel1_vpn_gateway_outside_address: "{{ item.tunnel1_vpn_gateway_outside_address }}"
tunnel1_vpn_gateway_inside_address: "{{ item.tunnel1_vpn_gateway_inside_address }}"
tunnel1_vpn_gateway_inside_netmask: "{{ item.tunnel1_vpn_gateway_inside_netmask }}"
tunnel1_vpn_gateway_inside_cidr: "{{ item.tunnel1_vpn_gateway_inside_cidr }}"
tunnel1_vpn_gateway_bgp_asn: "{{ item.tunnel1_vpn_gateway_bgp_asn }}"
tunnel1_vpn_gateway_bgp_hold_time: "{{ item.tunnel1_vpn_gateway_bgp_hold_time }}"
# Tunnel 1, IKE
tunnel1_ike_authentication_protocol: "{{ item.tunnel1_ike_authentication_protocol }}"
tunnel1_ike_encryption_protocol: "{{ item.tunnel1_ike_encryption_protocol }}"
tunnel1_ike_lifetime: "{{ item.tunnel1_ike_lifetime }}"
tunnel1_ike_perfect_forward_secrecy: "{{ item.tunnel1_ike_perfect_forward_secrecy }}"
tunnel1_ike_mode: "{{ item.tunnel1_ike_mode }}"
tunnel1_ike_pre_shared_key: "{{ item.tunnel1_ike_pre_shared_key | regex_replace('^\\n\\s*(.*)\\n\\s*$', '\\1') }}"
keys:
vpn_connection:
value: "{{ vpn_connection }}"
top: '.'
items:
# General data
vpn_connection: vpn_connection
vpn_connection_id: ".[@id]"
customer_gateway_id: customer_gateway_id
vpn_gateway_id: vpn_gateway_id
vpn_connection_type: vpn_connection_type
# Tunnel 1, customer side
tunnel1_customer_gateway_outside_address: ipsec_tunnel[1]/customer_gateway/tunnel_outside_address/ip_address
tunnel1_customer_gateway_inside_address: ipsec_tunnel[1]/customer_gateway/tunnel_inside_address/ip_address
tunnel1_customer_gateway_inside_netmask: ipsec_tunnel[1]/customer_gateway/tunnel_inside_address/network_mask
tunnel1_customer_gateway_inside_cidr: ipsec_tunnel[1]/customer_gateway/tunnel_inside_address/network_cidr
tunnel1_customer_gateway_bgp_asn: ipsec_tunnel[1]/customer_gateway/bgp/asn
tunnel1_customer_gateway_bgp_hold_time: ipsec_tunnel[1]/customer_gateway/bgp/hold_time
# Tunnel 1, AWS side
tunnel1_vpn_gateway_outside_address: ipsec_tunnel[1]/vpn_gateway/tunnel_outside_address/ip_address
tunnel1_vpn_gateway_inside_address: ipsec_tunnel[1]/vpn_gateway/tunnel_inside_address/ip_address
tunnel1_vpn_gateway_inside_netmask: ipsec_tunnel[1]/vpn_gateway/tunnel_inside_address/network_mask
tunnel1_vpn_gateway_inside_cidr: ipsec_tunnel[1]/vpn_gateway/tunnel_inside_address/network_cidr
tunnel1_vpn_gateway_bgp_asn: ipsec_tunnel[1]/vpn_gateway/bgp/asn
tunnel1_vpn_gateway_bgp_hold_time: ipsec_tunnel[1]/vpn_gateway/bgp/hold_time
# Tunnel 1, IKE
tunnel1_ike_authentication_protocol: ipsec_tunnel[1]/ike/authentication_protocol
tunnel1_ike_encryption_protocol: ipsec_tunnel[1]/ike/encryption_protocol
tunnel1_ike_lifetime: ipsec_tunnel[1]/ike/lifetime
tunnel1_ike_perfect_forward_secrecy: ipsec_tunnel[1]/ike/perfect_forward_secrecy
tunnel1_ike_mode: ipsec_tunnel[1]/ike/mode
tunnel1_ike_pre_shared_key: ipsec_tunnel[1]/ike/pre_shared_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment