Skip to content

Commit

Permalink
elb_network_lb - change default state from 'absent' to 'present' (ans…
Browse files Browse the repository at this point in the history
…ible-collections#1167)

elb_network_lb - change default state from 'absent' to 'present'

SUMMARY
change default state from 'absent' to 'present' to match our usual behaviour.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
elb_network_lb
ADDITIONAL INFORMATION
See also: ansible/ansible#65468

Reviewed-by: Markus Bergholz <[email protected]>
  • Loading branch information
tremble authored May 26, 2022
1 parent fbb33ee commit 38540cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1167-elb_network_lb-state.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breaking_changes:
- elb_network_lb - the default value of ``state`` has changed from ``absent`` to ``present`` (https://github.com/ansible-collections/community.aws/pull/1167).
21 changes: 8 additions & 13 deletions plugins/modules/elb_network_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@
state:
description:
- Create or destroy the load balancer.
- The current default is C(absent). However, this behavior is inconsistent with other modules
and as such the default will change to C(present) in a release after 2022-06-01.
To maintain the existing behavior explicitly set I(state=absent).
- The default changed from C('absent') to C('present') in release 4.0.0.
choices: [ 'present', 'absent' ]
type: str
default: 'present'
tags:
description:
- A dictionary of one or more tags to assign to the load balancer.
Expand Down Expand Up @@ -448,28 +447,24 @@ def main():
subnets=dict(type='list', elements='str'),
subnet_mappings=dict(type='list', elements='dict'),
scheme=dict(default='internet-facing', choices=['internet-facing', 'internal']),
state=dict(choices=['present', 'absent'], type='str'),
state=dict(choices=['present', 'absent'], type='str', default='present'),
tags=dict(type='dict'),
wait_timeout=dict(type='int'),
wait=dict(type='bool'),
ip_address_type=dict(type='str', choices=['ipv4', 'dualstack'])
)
)

required_if = [
('state', 'present', ('subnets', 'subnet_mappings',), True)
]

module = AnsibleAWSModule(argument_spec=argument_spec,
required_if=required_if,
mutually_exclusive=[['subnets', 'subnet_mappings']])

# Check for subnets or subnet_mappings if state is present
state = module.params.get("state")
if state == 'present':
if module.params.get("subnets") is None and module.params.get("subnet_mappings") is None:
module.fail_json(msg="'subnets' or 'subnet_mappings' is required when state=present")

if state is None:
# See below, unless state==present we delete. Ouch.
module.deprecate('State currently defaults to absent. This is inconsistent with other modules'
' and the default will be changed to `present` in a release after 2022-06-01',
date='2022-06-01', collection_name='community.aws')

# Quick check of listeners parameters
listeners = module.params.get("listeners")
Expand Down
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins/modules/aws_kms.py pylint:ansible-deprecated-no-version
plugins/modules/aws_kms_info.py pylint:ansible-deprecated-no-version
plugins/modules/ec2_metric_alarm.py pylint:ansible-deprecated-no-version
plugins/modules/elb_network_lb.py pylint:ansible-deprecated-no-version
plugins/modules/iam_policy.py pylint:ansible-deprecated-no-version
plugins/modules/iam_role.py pylint:ansible-deprecated-no-version
plugins/modules/iam_user.py pylint:ansible-deprecated-no-version

0 comments on commit 38540cc

Please sign in to comment.