Skip to content

Commit

Permalink
Update default value of purge_tags to True (ansible-collections#1343)
Browse files Browse the repository at this point in the history
Update default value of purge_tags to True

SUMMARY
Complete the deprecation cycle and update purge_tags default value to True
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/acm_certificate.py
plugins/modules/cloudfront_distribution.py
plugins/modules/ec2_vpc_vpn.py
plugins/modules/kms_key.py
plugins/modules/rds_param_group.py
plugins/modules/route53_health_check.py
plugins/modules/route53_zone.py
plugins/modules/sqs_queue.py
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored Jul 11, 2022
1 parent 8b08e2f commit 988b3fe
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 83 deletions.
15 changes: 5 additions & 10 deletions acm_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
'''

EXAMPLES = '''
Expand Down Expand Up @@ -495,7 +495,7 @@ def main():
name_tag=dict(aliases=['name']),
private_key=dict(no_log=True),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
state=dict(default='present', choices=['present', 'absent']),
)
module = AnsibleAWSModule(
Expand All @@ -504,14 +504,6 @@ def main():
)
acm = ACMServiceManager(module)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

# Check argument requirements
if module.params['state'] == 'present':
# at least one of these should be specified.
Expand All @@ -532,6 +524,9 @@ def main():
desired_tags = None
if module.params.get('tags') is not None:
desired_tags = module.params['tags']
else:
# Because we're setting the Name tag, we need to explicitly not purge when tags isn't passed
module.params['purge_tags'] = False
if module.params.get('name_tag') is not None:
# The module was originally implemented to filter certificates based on the 'Name' tag.
# Other tags are not used to filter certificates.
Expand Down
12 changes: 2 additions & 10 deletions cloudfront_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
options:
Expand Down Expand Up @@ -2109,7 +2109,7 @@ def main():
distribution_id=dict(),
e_tag=dict(),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
alias=dict(),
aliases=dict(type='list', default=[], elements='str'),
purge_aliases=dict(type='bool', default=False),
Expand Down Expand Up @@ -2148,14 +2148,6 @@ def main():
]
)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

client = module.client('cloudfront', retry_decorator=AWSRetry.jittered_backoff())

validation_mgr = CloudFrontValidationManager(module)
Expand Down
12 changes: 2 additions & 10 deletions ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
extends_documentation_fragment:
- amazon.aws.ec2
- amazon.aws.aws
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
author:
- "Sloane Hertel (@s-hertel)"
options:
Expand Down Expand Up @@ -767,7 +767,7 @@ def main():
static_only=dict(default=False, type='bool'),
customer_gateway_id=dict(type='str'),
vpn_connection_id=dict(type='str'),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
routes=dict(type='list', default=[], elements='str'),
purge_routes=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=600),
Expand All @@ -777,14 +777,6 @@ def main():
supports_check_mode=True)
connection = module.client('ec2', retry_decorator=VPNRetry.jittered_backoff(retries=10))

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

state = module.params.get('state')
parameters = dict(module.params)

Expand Down
15 changes: 2 additions & 13 deletions kms_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
notes:
- There are known inconsistencies in the amount of time required for updates of KMS keys to be fully reflected on AWS.
Expand Down Expand Up @@ -734,9 +734,6 @@ def update_tags(connection, module, key, desired_tags, purge_tags):
if desired_tags is None:
return False

# purge_tags needs to be explicitly set, so an empty tags list means remove
# all tags

to_add, to_remove = compare_aws_tags(key['tags'], desired_tags, purge_tags)
if not (bool(to_add) or bool(to_remove)):
return False
Expand Down Expand Up @@ -950,7 +947,7 @@ def main():
description=dict(),
enabled=dict(type='bool', default=True),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
grants=dict(type='list', default=[], elements='dict'),
policy=dict(type='json'),
purge_grants=dict(type='bool', default=False),
Expand All @@ -969,14 +966,6 @@ def main():

kms = module.client('kms')

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

module.deprecate("The 'policies' return key is deprecated and will be replaced by 'key_policies'. Both values are returned for now.",
date='2024-05-01', collection_name='community.aws')

Expand Down
12 changes: 2 additions & 10 deletions rds_param_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
'''

Expand Down Expand Up @@ -315,22 +315,14 @@ def main():
params=dict(aliases=['parameters'], type='dict'),
immediate=dict(type='bool', aliases=['apply_immediately']),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
)
module = AnsibleAWSModule(
argument_spec=argument_spec,
required_if=[['state', 'present', ['description', 'engine']]],
supports_check_mode=True
)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

try:
conn = module.client('rds', retry_decorator=AWSRetry.jittered_backoff())
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
Expand Down
12 changes: 2 additions & 10 deletions route53_health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
'''

EXAMPLES = '''
Expand Down Expand Up @@ -503,7 +503,7 @@ def main():
request_interval=dict(type='int', choices=[10, 30], default=30),
failure_threshold=dict(type='int', choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
health_check_id=dict(type='str', aliases=['id'], required=False),
health_check_name=dict(type='str', aliases=['name'], required=False),
use_unique_names=dict(type='bool', required=False),
Expand Down Expand Up @@ -537,14 +537,6 @@ def main():
supports_check_mode=True,
)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

if not module.params.get('health_check_id') and not module.params.get('type'):
module.fail_json(msg="parameter 'type' is required if not updating or deleting health check by ID.")

Expand Down
12 changes: 2 additions & 10 deletions route53_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
notes:
- Support for I(tags) and I(purge_tags) was added in release 2.1.0.
author:
Expand Down Expand Up @@ -437,7 +437,7 @@ def main():
hosted_zone_id=dict(),
delegation_set_id=dict(),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
)

mutually_exclusive = [
Expand All @@ -451,14 +451,6 @@ def main():
supports_check_mode=True,
)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

zone_in = module.params.get('zone').lower()
state = module.params.get('state').lower()
vpc_id = module.params.get('vpc_id')
Expand Down
12 changes: 2 additions & 10 deletions sqs_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
'''

RETURN = r'''
Expand Down Expand Up @@ -474,18 +474,10 @@ def main():
kms_data_key_reuse_period_seconds=dict(type='int', aliases=['kms_data_key_reuse_period'], no_log=False),
content_based_deduplication=dict(type='bool'),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
)
module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True)

if module.params.get('purge_tags') is None:
module.deprecate(
'The purge_tags parameter currently defaults to False.'
' For consistency across the collection, this default value'
' will change to True in release 5.0.0.',
version='5.0.0', collection_name='community.aws')
module.params['purge_tags'] = False

state = module.params.get('state')
retry_decorator = AWSRetry.jittered_backoff(catch_extra_error_codes=['AWS.SimpleQueueService.NonExistentQueue'])
try:
Expand Down

0 comments on commit 988b3fe

Please sign in to comment.