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

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

Merged
Show file tree
Hide file tree
Changes from all 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/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