Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable integration tests for elb_network_lb #1365

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/1365-elb_network_lb-ip_address_type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- elb_network_lb - fixes bug where ``ip_address_type`` in return value was not updated (https://github.com/ansible-collections/community.aws/pull/1365).
244 changes: 126 additions & 118 deletions plugins/modules/elb_network_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,138 +183,144 @@
'''

RETURN = r'''
availability_zones:
description: The Availability Zones for the load balancer.
load_balancer:
description: A representation of the Network Load Balancer
returned: when state is present
type: list
sample: "[{'subnet_id': 'subnet-aabbccddff', 'zone_name': 'ap-southeast-2a', 'load_balancer_addresses': []}]"
canonical_hosted_zone_id:
description: The ID of the Amazon Route 53 hosted zone associated with the load balancer.
returned: when state is present
type: str
sample: ABCDEF12345678
created_time:
description: The date and time the load balancer was created.
returned: when state is present
type: str
sample: "2015-02-12T02:14:02+00:00"
deletion_protection_enabled:
description: Indicates whether deletion protection is enabled.
returned: when state is present
type: str
sample: true
dns_name:
description: The public DNS name of the load balancer.
returned: when state is present
type: str
sample: internal-my-elb-123456789.ap-southeast-2.elb.amazonaws.com
idle_timeout_timeout_seconds:
description: The idle timeout value, in seconds.
returned: when state is present
type: str
sample: 60
ip_address_type:
description: The type of IP addresses used by the subnets for the load balancer.
returned: when state is present
type: str
sample: ipv4
listeners:
description: Information about the listeners.
returned: when state is present
type: complex
type: dict
version_added: 5.0.0
contains:
listener_arn:
description: The Amazon Resource Name (ARN) of the listener.
availability_zones:
description: The Availability Zones for the load balancer.
returned: when state is present
type: list
sample: "[{'subnet_id': 'subnet-aabbccddff', 'zone_name': 'ap-southeast-2a', 'load_balancer_addresses': []}]"
canonical_hosted_zone_id:
description: The ID of the Amazon Route 53 hosted zone associated with the load balancer.
returned: when state is present
type: str
sample: ""
load_balancer_arn:
description: The Amazon Resource Name (ARN) of the load balancer.
sample: ABCDEF12345678
created_time:
description: The date and time the load balancer was created.
returned: when state is present
type: str
sample: ""
port:
description: The port on which the load balancer is listening.
sample: "2015-02-12T02:14:02+00:00"
deletion_protection_enabled:
description: Indicates whether deletion protection is enabled.
returned: when state is present
type: int
sample: 80
protocol:
description: The protocol for connections from clients to the load balancer.
type: str
sample: true
dns_name:
description: The public DNS name of the load balancer.
returned: when state is present
type: str
sample: HTTPS
certificates:
description: The SSL server certificate.
sample: internal-my-elb-123456789.ap-southeast-2.elb.amazonaws.com
idle_timeout_timeout_seconds:
description: The idle timeout value, in seconds.
returned: when state is present
type: str
sample: 60
ip_address_type:
description: The type of IP addresses used by the subnets for the load balancer.
returned: when state is present
type: str
sample: ipv4
listeners:
description: Information about the listeners.
returned: when state is present
type: complex
contains:
certificate_arn:
description: The Amazon Resource Name (ARN) of the certificate.
listener_arn:
description: The Amazon Resource Name (ARN) of the listener.
returned: when state is present
type: str
sample: ""
ssl_policy:
description: The security policy that defines which ciphers and protocols are supported.
returned: when state is present
type: str
sample: ""
default_actions:
description: The default actions for the listener.
returned: when state is present
type: str
contains:
type:
description: The type of action.
load_balancer_arn:
description: The Amazon Resource Name (ARN) of the load balancer.
returned: when state is present
type: str
sample: ""
target_group_arn:
description: The Amazon Resource Name (ARN) of the target group.
port:
description: The port on which the load balancer is listening.
returned: when state is present
type: int
sample: 80
protocol:
description: The protocol for connections from clients to the load balancer.
returned: when state is present
type: str
sample: HTTPS
certificates:
description: The SSL server certificate.
returned: when state is present
type: complex
contains:
certificate_arn:
description: The Amazon Resource Name (ARN) of the certificate.
returned: when state is present
type: str
sample: ""
ssl_policy:
description: The security policy that defines which ciphers and protocols are supported.
returned: when state is present
type: str
sample: ""
load_balancer_arn:
description: The Amazon Resource Name (ARN) of the load balancer.
returned: when state is present
type: str
sample: arn:aws:elasticloadbalancing:ap-southeast-2:0123456789:loadbalancer/app/my-elb/001122334455
load_balancer_name:
description: The name of the load balancer.
returned: when state is present
type: str
sample: my-elb
load_balancing_cross_zone_enabled:
description: Indicates whether cross-zone load balancing is enabled.
returned: when state is present
type: str
sample: true
scheme:
description: Internet-facing or internal load balancer.
returned: when state is present
type: str
sample: internal
state:
description: The state of the load balancer.
returned: when state is present
type: dict
sample: "{'code': 'active'}"
tags:
description: The tags attached to the load balancer.
returned: when state is present
type: dict
sample: "{
'Tag': 'Example'
}"
type:
description: The type of load balancer.
returned: when state is present
type: str
sample: network
vpc_id:
description: The ID of the VPC for the load balancer.
returned: when state is present
type: str
sample: vpc-0011223344
default_actions:
description: The default actions for the listener.
returned: when state is present
type: str
contains:
type:
description: The type of action.
returned: when state is present
type: str
sample: ""
target_group_arn:
description: The Amazon Resource Name (ARN) of the target group.
returned: when state is present
type: str
sample: ""
load_balancer_arn:
description: The Amazon Resource Name (ARN) of the load balancer.
returned: when state is present
type: str
sample: arn:aws:elasticloadbalancing:ap-southeast-2:0123456789:loadbalancer/app/my-elb/001122334455
load_balancer_name:
description: The name of the load balancer.
returned: when state is present
type: str
sample: my-elb
load_balancing_cross_zone_enabled:
description: Indicates whether cross-zone load balancing is enabled.
returned: when state is present
type: str
sample: true
scheme:
description: Internet-facing or internal load balancer.
returned: when state is present
type: str
sample: internal
state:
description: The state of the load balancer.
returned: when state is present
type: dict
sample: "{'code': 'active'}"
tags:
description: The tags attached to the load balancer.
returned: when state is present
type: dict
sample: "{
'Tag': 'Example'
}"
type:
description: The type of load balancer.
returned: when state is present
type: str
sample: network
vpc_id:
description: The ID of the VPC for the load balancer.
returned: when state is present
type: str
sample: vpc-0011223344
'''

from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
Expand Down Expand Up @@ -379,19 +385,18 @@ def create_or_update_elb(elb_obj):
if listeners_obj.changed:
elb_obj.changed = True

# Update ELB ip address type only if option has been provided
if elb_obj.module.params.get('ip_address_type') is not None:
elb_obj.modify_ip_address_type(elb_obj.module.params.get('ip_address_type'))

# Update the objects to pickup changes
# Get the ELB again
elb_obj.update()

# Get the ELB listeners again
listeners_obj.update()

# Update the ELB attributes
elb_obj.update_elb_attributes()

# Update ELB ip address type only if option has been provided
if elb_obj.module.params.get('ip_address_type') is not None:
elb_obj.modify_ip_address_type(elb_obj.module.params.get('ip_address_type'))

# Convert to snake_case and merge in everything we want to return to the user
snaked_elb = camel_dict_to_snake_dict(elb_obj.elb)
snaked_elb.update(camel_dict_to_snake_dict(elb_obj.elb_attributes))
Expand All @@ -405,7 +410,10 @@ def create_or_update_elb(elb_obj):
# ip address type
snaked_elb['ip_address_type'] = elb_obj.get_elb_ip_address_type()

elb_obj.module.exit_json(changed=elb_obj.changed, **snaked_elb)
elb_obj.module.exit_json(
changed=elb_obj.changed,
load_balancer=snaked_elb,
tremble marked this conversation as resolved.
Show resolved Hide resolved
**snaked_elb)


def delete_elb(elb_obj):
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/targets/elb_network_lb/aliases
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# reason: missing-policy
tremble marked this conversation as resolved.
Show resolved Hide resolved
# reason: broken
# The SSL cert stored in the test has expired. Should be dynamically generated.
disabled

tremble marked this conversation as resolved.
Show resolved Hide resolved
cloud/aws
6 changes: 3 additions & 3 deletions tests/integration/targets/elb_network_lb/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# load balancer and target group names have to be less than 32 characters
# the 8 digit identifier at the end of resource_prefix helps determine during which test something
# was created and allows tests to be run in parallel
nlb_name: "my-nlb-{{ resource_prefix | regex_search('([0-9]+)$') }}"
tg_name: "my-tg-{{ resource_prefix | regex_search('([0-9]+)$') }}"
tg_tcpudp_name: "my-tg-tcpudp-{{ resource_prefix | regex_search('([0-9]+)$') }}"
nlb_name: "nlb-{{ tiny_prefix }}"
tg_name: "nlb-{{ tiny_prefix }}"
tg_tcpudp_name: "nlb-tcp-udp-{{ tiny_prefix }}"
32 changes: 0 additions & 32 deletions tests/integration/targets/elb_network_lb/files/cert.pem

This file was deleted.

52 changes: 0 additions & 52 deletions tests/integration/targets/elb_network_lb/files/key.pem

This file was deleted.

Loading