Skip to content

Commit

Permalink
New module: Add ec2 Vpn Connection module and tests (cloud/amazon/ec2…
Browse files Browse the repository at this point in the history
…_vpc_vpn) (ansible#24385)

* Add VPN module and unittests

* remove unnecessary imports

* fix documentation

* raise custom exception rather than passing module everywhere

* remove recordings

Rerecord tests

Fix docs

Ensure vpn_connection_id is a list of strings when checking if it exists

* fix check mode

* Rerecord tests

* remove superfluous code and comments and make exception handling uniform

fix docs

* Fix ec2_vpc_vpn documentation

* make ec2_vpc_vpn compatible with python 2.6 and make check mode logic more succinct

* fix comparison of list of dicts

* Fix typos and docstrings

make requested changes for imports

make code clearer

* Fix copyright and metadata version.
  • Loading branch information
s-hertel authored and ansibot committed Aug 24, 2017
1 parent 8d3546a commit cf1a9d4
Show file tree
Hide file tree
Showing 113 changed files with 7,209 additions and 0 deletions.
721 changes: 721 additions & 0 deletions lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"data": {
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "cd85ac52-d6bb-4359-a3f9-2a38da538ba2",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:29 GMT"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"data": {
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "317446c6-62c4-4204-9987-d9a203bd71f8",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:29 GMT"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"status_code": 200,
"data": {
"VpnConnection": {
"VpnConnectionId": "vpn-c0d1cad2",
"CustomerGatewayConfiguration": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-c0d1cad2\">\n <customer_gateway_id>cgw-6113c87f</customer_gateway_id>\n <vpn_gateway_id>vgw-35d70c2b</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>9.8.7.6</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.12.250</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.208.26.210</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.12.249</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>4PcswUCk9jOKcg0x6aVID9o5w73l0d0f</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>9.8.7.6</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.14.170</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>35.166.98.185</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.14.169</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>SGvO3U_dG.ofdKmpsDZsXsnZj7iWoZ.F</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>\n",
"Routes": [],
"State": "pending",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Options": {
"StaticRoutesOnly": true
}
},
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "c02e6144-46bc-4da3-a15b-0695e6ef1fa4",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:28 GMT"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"data": {
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "0e3d9efd-85ad-4942-b2e8-85ceaf577cf8",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:31 GMT"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"status_code": 200,
"data": {
"VpnConnections": [
{
"VpnConnectionId": "vpn-d6d1cac4",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-d4d1cac6",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-dad1cac8",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-d8d1caca",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-d9d1cacb",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-ded1cacc",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-dfd1cacd",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-dcd1cace",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-ddd1cacf",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-c2d1cad0",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
},
{
"VpnConnectionId": "vpn-c3d1cad1",
"Routes": [],
"State": "deleted",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "63558231-3b8b-4ee1-ab6c-cb0816524784",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:27 GMT"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"status_code": 200,
"data": {
"VpnConnections": [
{
"VpnConnectionId": "vpn-c0d1cad2",
"CustomerGatewayConfiguration": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn_connection id=\"vpn-c0d1cad2\">\n <customer_gateway_id>cgw-6113c87f</customer_gateway_id>\n <vpn_gateway_id>vgw-35d70c2b</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>9.8.7.6</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.12.250</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.208.26.210</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.12.249</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>4PcswUCk9jOKcg0x6aVID9o5w73l0d0f</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>9.8.7.6</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.14.170</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>35.166.98.185</ip_address>\n </tunnel_outside_address>\n <tunnel_inside_address>\n <ip_address>169.254.14.169</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>SGvO3U_dG.ofdKmpsDZsXsnZj7iWoZ.F</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>\n",
"Routes": [],
"VgwTelemetry": [
{
"Status": "DOWN",
"AcceptedRouteCount": 0,
"OutsideIpAddress": "34.208.26.210",
"LastStatusChange": {
"hour": 20,
"__class__": "datetime",
"month": 6,
"second": 28,
"microsecond": 0,
"year": 2017,
"day": 12,
"minute": 23
},
"StatusMessage": ""
},
{
"Status": "DOWN",
"AcceptedRouteCount": 0,
"OutsideIpAddress": "35.166.98.185",
"LastStatusChange": {
"hour": 20,
"__class__": "datetime",
"month": 6,
"second": 28,
"microsecond": 0,
"year": 2017,
"day": 12,
"minute": 23
},
"StatusMessage": ""
}
],
"State": "pending",
"VpnGatewayId": "vgw-35d70c2b",
"CustomerGatewayId": "cgw-6113c87f",
"Type": "ipsec.1",
"Options": {
"StaticRoutesOnly": true
}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "5947bc65-4a3f-4b20-898c-47cc8e72d05b",
"HTTPHeaders": {
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"server": "AmazonEC2",
"content-type": "text/xml;charset=UTF-8",
"date": "Mon, 12 Jun 2017 20:23:29 GMT"
}
}
}
}
Loading

0 comments on commit cf1a9d4

Please sign in to comment.