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

ec2_elb_lb boto3 migration #377

Merged
merged 38 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
945a88a
Remove boilerplate tests, we're using common code to create clients
tremble May 28, 2021
c17c446
rename ec2_elb_lb elb_classic_lb
tremble Aug 13, 2021
7a388b0
Update argument_spec to use standard formating
tremble May 28, 2021
9739977
remove required=False and default=None
tremble May 28, 2021
0581560
Let AnsibleModule validate required_if parameters
tremble May 28, 2021
c2eb85b
remove region from examples
tremble Aug 13, 2021
0cc519e
Initial migration to boto3 (no update support)
tremble May 28, 2021
6c23d1b
Add waiters on creation / deletion
tremble Aug 16, 2021
6cedf38
Add retry decorators on standard calls.
tremble Aug 16, 2021
06a8218
Add minimal tests for ELBs
tremble Aug 16, 2021
dafcff2
Add support for updating schema
tremble Aug 16, 2021
f466c87
Add support for updating the Subnets associated with an ELB
tremble Aug 17, 2021
cc81d66
Add support for updating the Zones associated with an ELB
tremble Aug 17, 2021
8a3891e
Rename elb integration test to elb_classic_lb and update module name …
tremble Aug 17, 2021
d612aa9
update metadata to add elb_classic_lb to aws group
tremble Aug 17, 2021
d1734b7
Add support for managing ELB Classic Security Groups (by ID)
tremble Aug 17, 2021
e1a8c74
Add support for updating listeners
tremble Aug 18, 2021
c0e1c36
Make sure the boto3 style LB we return is updated before being passed…
tremble Aug 18, 2021
21888c0
Add support for managing Health Checks
tremble Aug 18, 2021
415767d
Minor linting
tremble Aug 18, 2021
7d4d976
Add support for managing ELB tags
tremble Aug 18, 2021
5ed41af
Add initial support for setting attributes
tremble Aug 19, 2021
ce340e0
split out region/AZ discovery
tremble Aug 19, 2021
447028f
bump default timeout - have seen interface deletion take about 150s
tremble Aug 19, 2021
a8186a4
Add initial support for configuring proxy policies for listeners
tremble Aug 19, 2021
511c9bc
Add support for managing ELB Stickiness policies
tremble Aug 21, 2021
69c147c
Add support for managing instance attachments
tremble Aug 22, 2021
525d138
Add support for managing S3 logging
tremble Aug 23, 2021
cc6c0b3
mark ELB tests as slow
tremble Aug 24, 2021
3bda7b2
Add support for setting Security Groups by Name
tremble Aug 24, 2021
969ef5b
listener - ssl
tremble Aug 24, 2021
e5b567e
Add additional validation for things that standard validation can't c…
tremble Aug 24, 2021
9f25ed0
Add breaking change changelog for removal of ansible_facts
tremble Aug 25, 2021
e8c86a7
Add documentation for the elb return values.
tremble Aug 25, 2021
39e8e3c
Use tiny_prefix for the S3 bucket names - we hit the 63 character lim…
tremble Aug 25, 2021
ab2107d
changelog - error messages changed
tremble Sep 1, 2021
c1e29d2
Re-add fact
tremble Sep 5, 2021
b4f3fc9
Bump version_added notes
tremble Sep 28, 2021
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
8 changes: 8 additions & 0 deletions changelogs/fragments/377-ec2_elb_lb-boto3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
minor_changes:
tremble marked this conversation as resolved.
Show resolved Hide resolved
- ec2_elb_lb - module renamed to ``elb_classic_lb`` (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - migrated to boto3 SDK (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - added support for check_mode (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - added support for wait during creation (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - added support for wait during instance addition and removal (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - added retries on common AWS temporary API failures (https://github.com/ansible-collections/amazon.aws/pull/377).
- elb_classic_lb - various error messages changed due to refactor (https://github.com/ansible-collections/amazon.aws/pull/377).
3 changes: 3 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ action_groups:
- ec2_vpc_net_info
- ec2_vpc_subnet
- ec2_vpc_subnet_info
- elb_classic_lb
- s3_bucket
- ec2_vpc_endpoint_facts
- ec2_vpc_endpoint
Expand Down Expand Up @@ -97,6 +98,8 @@ plugin_routing:
warning_text: >-
ec2_ami_facts was renamed in Ansible 2.9 to ec2_ami_info.
Please update your tasks.
ec2_elb_lb:
redirect: amazon.aws.elb_classic_lb
ec2_eni_facts:
deprecation:
removal_date: 2021-12-01
Expand Down
157 changes: 157 additions & 0 deletions plugins/module_utils/waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@
},
]
},
"NetworkInterfaceDeleted": {
"operation": "DescribeNetworkInterfaces",
"delay": 5,
"maxAttempts": 40,
"acceptors": [
{
"matcher": "path",
"expected": True,
"argument": "length(NetworkInterfaces[]) > `0`",
"state": "retry"
},
{
"matcher": "path",
"expected": True,
"argument": "length(NetworkInterfaces[]) == `0`",
"state": "success"
},
{
"expected": "InvalidNetworkInterfaceID.NotFound",
"matcher": "error",
"state": "success"
},
]
},
"NetworkInterfaceDeleteOnTerminate": {
"operation": "DescribeNetworkInterfaces",
"delay": 5,
Expand Down Expand Up @@ -462,6 +486,98 @@
}


elb_data = {
"version": 2,
"waiters": {
"AnyInstanceInService": {
"acceptors": [
{
"argument": "InstanceStates[].State",
"expected": "InService",
"matcher": "pathAny",
"state": "success"
}
],
"delay": 15,
"maxAttempts": 40,
"operation": "DescribeInstanceHealth"
},
"InstanceDeregistered": {
"delay": 15,
"operation": "DescribeInstanceHealth",
"maxAttempts": 40,
"acceptors": [
{
"expected": "OutOfService",
"matcher": "pathAll",
"state": "success",
"argument": "InstanceStates[].State"
},
{
"matcher": "error",
"expected": "InvalidInstance",
"state": "success"
}
]
},
"InstanceInService": {
"acceptors": [
{
"argument": "InstanceStates[].State",
"expected": "InService",
"matcher": "pathAll",
"state": "success"
},
{
"matcher": "error",
"expected": "InvalidInstance",
"state": "retry"
}
],
"delay": 15,
"maxAttempts": 40,
"operation": "DescribeInstanceHealth"
},
"LoadBalancerCreated": {
"delay": 10,
"maxAttempts": 60,
"operation": "DescribeLoadBalancers",
"acceptors": [
{
"matcher": "path",
"expected": True,
"argument": "length(LoadBalancerDescriptions[]) > `0`",
"state": "success",
},
{
"matcher": "error",
"expected": "LoadBalancerNotFound",
"state": "retry",
},
],
},
"LoadBalancerDeleted": {
"delay": 10,
"maxAttempts": 60,
"operation": "DescribeLoadBalancers",
"acceptors": [
{
"matcher": "path",
"expected": True,
"argument": "length(LoadBalancerDescriptions[]) > `0`",
"state": "retry",
},
{
"matcher": "error",
"expected": "LoadBalancerNotFound",
"state": "success",
},
],
},
}
}


rds_data = {
"version": 2,
"waiters": {
Expand Down Expand Up @@ -572,6 +688,11 @@ def eks_model(name):
return eks_models.get_waiter(name)


def elb_model(name):
elb_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(elb_data))
return elb_models.get_waiter(name)


def rds_model(name):
rds_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(rds_data))
return rds_models.get_waiter(name)
Expand Down Expand Up @@ -601,6 +722,12 @@ def route53_model(name):
core_waiter.NormalizedOperationMethod(
ec2.describe_network_interfaces
)),
('EC2', 'network_interface_deleted'): lambda ec2: core_waiter.Waiter(
'network_interface_deleted',
ec2_model('NetworkInterfaceDeleted'),
core_waiter.NormalizedOperationMethod(
ec2.describe_network_interfaces
)),
('EC2', 'network_interface_available'): lambda ec2: core_waiter.Waiter(
'network_interface_available',
ec2_model('NetworkInterfaceAvailable'),
Expand Down Expand Up @@ -745,6 +872,36 @@ def route53_model(name):
core_waiter.NormalizedOperationMethod(
eks.describe_cluster
)),
('ElasticLoadBalancing', 'any_instance_in_service'): lambda elb: core_waiter.Waiter(
'any_instance_in_service',
elb_model('AnyInstanceInService'),
core_waiter.NormalizedOperationMethod(
elb.describe_instance_health
)),
('ElasticLoadBalancing', 'instance_deregistered'): lambda elb: core_waiter.Waiter(
'instance_deregistered',
elb_model('InstanceDeregistered'),
core_waiter.NormalizedOperationMethod(
elb.describe_instance_health
)),
('ElasticLoadBalancing', 'instance_in_service'): lambda elb: core_waiter.Waiter(
'load_balancer_created',
elb_model('InstanceInService'),
core_waiter.NormalizedOperationMethod(
elb.describe_instance_health
)),
('ElasticLoadBalancing', 'load_balancer_created'): lambda elb: core_waiter.Waiter(
'load_balancer_created',
elb_model('LoadBalancerCreated'),
core_waiter.NormalizedOperationMethod(
elb.describe_load_balancers
)),
('ElasticLoadBalancing', 'load_balancer_deleted'): lambda elb: core_waiter.Waiter(
'load_balancer_deleted',
elb_model('LoadBalancerDeleted'),
core_waiter.NormalizedOperationMethod(
elb.describe_load_balancers
)),
('RDS', 'db_instance_stopped'): lambda rds: core_waiter.Waiter(
'db_instance_stopped',
rds_model('DBInstanceStopped'),
Expand Down
Loading