Skip to content

Commit

Permalink
Modify upon review
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
  • Loading branch information
alinabuzachis committed Oct 3, 2024
1 parent de59391 commit 94a960b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 63 deletions.
65 changes: 24 additions & 41 deletions plugins/modules/ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@
description: If the VPN connection has changed.
type: bool
returned: always
sample:
changed: true
sample: true
customer_gateway_configuration:
description: The configuration of the VPN connection.
returned: O(state=present)
Expand All @@ -249,26 +248,22 @@
description: The customer gateway connected via the connection.
type: str
returned: O(state=present)
sample:
customer_gateway_id: "cgw-1220c87b"
sample: "cgw-1220c87b"
gateway_association_state:
description: The current state of the gateway association.
type: str
returned: O(state=present)
sample:
gateway_association_state: "associated"
sample: "associated"
vpn_gateway_id:
description: The virtual private gateway connected via the connection.
type: str
returned: O(state=present)
sample:
vpn_gateway_id: "vgw-cb0ae2a2"
sample: "vgw-cb0ae2a2"
transit_gateway_id:
description: The transit gateway id to which the vpn connection can be attached.
type: str
returned: O(state=present)
sample:
transit_gateway_id: "tgw-cb0ae2a2"
sample: "tgw-cb0ae2a2"
options:
description: The VPN connection options.
type: list
Expand All @@ -279,45 +274,38 @@
description: If the VPN connection only allows static routes.
returned: O(state=present)
type: bool
sample:
static_routes_only: true
sample: true
enable_acceleration:
description: Indicates whether acceleration is enabled for the VPN connection.
returned: O(state=present)
type: bool
sample:
enable_acceleration: false
sample: false
local_ipv4_network_cidr:
description: The IPv4 CIDR on the customer gateway (on-premises) side of the VPN connection.
returned: O(state=present)
type: str
sample:
local_ipv4_network_cidr: "0.0.0.0/0"
sample: "0.0.0.0/0"
outside_ip_address_type:
description: The external IP address of the VPN tunnel.
returned: O(state=present)
type: str
sample:
outside_ip_address_type: "PublicIpv4"
sample: "PublicIpv4"
remote_ipv4_network_cidr:
description: The IPv4 CIDR on the Amazon Web Services side of the VPN connection.
returned: O(state=present)
type: str
sample:
remote_ipv4_network_cidr: "0.0.0.0/0"
sample: "0.0.0.0/0"
tunnel_inside_ip_version:
description: Indicates whether the VPN tunnels process IPv4 or IPv6 traffic.
returned: O(state=present)
type: str
sample:
tunnel_inside_ip_version: "ipv4"
sample: "ipv4"
tunnel_options:
description: Indicates the VPN tunnel options.
returned: O(state=present)
type: list
elements: dict
sample:
tunnel_inside_ip_version: [
sample: [
{
"log_options": {
"cloud_watch_log_options": {
Expand Down Expand Up @@ -357,8 +345,7 @@
description: The routes of the VPN connection.
type: list
returned: O(state=present)
sample:
routes: [{
sample: [{
"destination_cidr_block": "192.168.1.0/24",
"state": "available"
}]
Expand All @@ -380,28 +367,25 @@
description: The status of the VPN connection.
type: str
returned: O(state=present)
sample:
state: "available"
sample: "available"
tags:
description: The tags associated with the connection.
type: dict
returned:O(state=present)
sample:
tags:
name: "ansible-test"
other: "tag"
sample: {
"name": "ansible-test"
"other": "tag"
}
type:
description: The type of VPN connection (currently only ipsec.1 is available).
type: str
returned: V(state=present)
sample:
type: "ipsec.1"
sample: "ipsec.1"
vgw_telemetry:
type: list
returned: O(state=present)
description: The telemetry for the VPN tunnel.
sample:
vgw_telemetry: [
sample: [
{
"accepted_route_count": 0,
"last_status_change": "2024-09-30T13:12:33+00:00",
Expand Down Expand Up @@ -440,8 +424,7 @@
description: The identifier for the VPN connection.
type: str
returned: O(state=present)
sample:
vpn_connection_id: "vpn-781e0e19"
sample: "vpn-781e0e19"
"""

try:
Expand Down Expand Up @@ -733,15 +716,15 @@ def check_for_routes_update(client, module: AnsibleAWSModule, vpn_connection_id:
if attribute in ("tags", "routes", "state"):
continue
elif attribute == "options":
will_be = module.params.get("static_only", None)
will_be = module.params.get("static_only")
is_now = bool(current_attrs[attribute]["static_routes_only"])
attribute = "static_only"
elif attribute == "type":
will_be = module.params.get("connection_type", None)
will_be = module.params.get("connection_type")
is_now = current_attrs[attribute]
else:
is_now = current_attrs[attribute]
will_be = module.params.get(attribute, None)
will_be = module.params.get(attribute)

if will_be is not None and to_text(will_be) != to_text(is_now):
module.fail_json(
Expand Down
26 changes: 9 additions & 17 deletions plugins/modules/ec2_vpc_vpn_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,45 +87,38 @@
description: If the VPN connection only allows static routes.
returned: O(state=present)
type: bool
sample:
static_routes_only: true
sample: true
enable_acceleration:
description: Indicates whether acceleration is enabled for the VPN connection.
returned: O(state=present)
type: bool
sample:
enable_acceleration: false
sample: false
local_ipv4_network_cidr:
description: The IPv4 CIDR on the customer gateway (on-premises) side of the VPN connection.
returned: O(state=present)
type: str
sample:
local_ipv4_network_cidr: "0.0.0.0/0"
sample: "0.0.0.0/0"
outside_ip_address_type:
description: The external IP address of the VPN tunnel.
returned: O(state=present)
type: str
sample:
outside_ip_address_type: "PublicIpv4"
sample: "PublicIpv4"
remote_ipv4_network_cidr:
description: The IPv4 CIDR on the Amazon Web Services side of the VPN connection.
returned: O(state=present)
type: str
sample:
remote_ipv4_network_cidr: "0.0.0.0/0"
sample: "0.0.0.0/0"
tunnel_inside_ip_version:
description: Indicates whether the VPN tunnels process IPv4 or IPv6 traffic.
returned: O(state=present)
type: str
sample:
tunnel_inside_ip_version: "ipv4"
sample: "ipv4"
tunnel_options:
description: Indicates the VPN tunnel options.
returned: O(state=present)
type: list
elements: dict
sample:
tunnel_inside_ip_version: [
sample: [
{
"log_options": {
"cloud_watch_log_options": {
Expand Down Expand Up @@ -180,7 +173,7 @@
state:
description: The current state of the static route.
type: str
returned: O(state=present)
returned: O(state=present)
state:
description: The current state of the VPN connection.
returned: always
Expand All @@ -189,8 +182,7 @@
tags:
description: Any tags assigned to the VPN connection.
returned: always
type: dict
sample: {
type: {
"Name": "test-conn"
}
type:
Expand Down
13 changes: 8 additions & 5 deletions tests/integration/targets/ec2_vpc_vpn/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
- result is failed
- result.msg == "parameters are mutually exclusive: vpn_gateway_id|transit_gateway_id"


- name: Create EC2 VPN Connection, with customer gateway and transit_gateway
community.aws.ec2_vpc_vpn:
customer_gateway_id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}'
Expand Down Expand Up @@ -141,7 +140,8 @@
register: result
check_mode: true

- ansible.builtin.assert:
- name: Assert EC2 VPN Connection is deleted (check_mode)
ansible.builtin.assert:
that:
- result is changed

Expand All @@ -151,7 +151,8 @@
vpn_connection_id: '{{ vpn_id }}'
register: result

- ansible.builtin.assert:
- name: Assert EC2 VPN Connection is deleted
ansible.builtin.assert:
that:
- result is changed

Expand All @@ -162,7 +163,8 @@
register: result
check_mode: true

- ansible.builtin.assert:
- name: Assert result has not changed (idempotency check_mode)
ansible.builtin.assert:
that:
- result is not changed

Expand All @@ -172,7 +174,8 @@
vpn_connection_id: '{{ vpn_id }}'
register: result

- ansible.builtin.assert:
- name: Assert result has not changed (idempotency)
ansible.builtin.assert:
that:
- result is not changed

Expand Down

0 comments on commit 94a960b

Please sign in to comment.