Skip to content

Commit

Permalink
Update default value for purge_tags (#916)
Browse files Browse the repository at this point in the history
Update default value for purge_tags

SUMMARY
Update purge_tags default value to True for various modules.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/ec2_ami.py
plugins/modules/ec2_instance.py
plugins/modules/ec2_key.py
plugins/modules/ec2_vol.py
plugins/modules/ec2_vpc_endpoint.py
plugins/modules/ec2_vpc_net.py
plugins/modules/ec2_vpc_route_table.py
ADDITIONAL INFORMATION

Reviewed-by: Joseph Torcasso <None>
  • Loading branch information
tremble authored Jul 7, 2022
1 parent ea8d954 commit 86a1c1f
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 265 deletions.
8 changes: 8 additions & 0 deletions changelogs/fragments/916-purge_tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
breaking_changes:
- ec2_ami - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_instance - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_key - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_vol - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_vpc_endpoint - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_vpc_net - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
- ec2_vpc_route_table - the default value for ``purge_tags`` has been changed from ``False`` to ``True`` (https://github.com/ansible-collections/amazon.aws/pull/916).
84 changes: 39 additions & 45 deletions plugins/modules/ec2_ami.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
type: str
architecture:
description:
- The target architecture of the image to register
- The target architecture of the image to register.
default: "x86_64"
type: str
kernel_id:
Expand Down Expand Up @@ -76,61 +76,63 @@
type: list
elements: dict
suboptions:
device_name:
type: str
description:
device_name:
type: str
description:
- The device name. For example C(/dev/sda).
required: yes
virtual_name:
type: str
description:
required: yes
virtual_name:
type: str
description:
- The virtual name for the device.
- See the AWS documentation for more detail U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html).
no_device:
type: bool
description:
no_device:
type: bool
description:
- Suppresses the specified device included in the block device mapping of the AMI.
volume_type:
type: str
description: The volume type. Defaults to C(gp2) when not set.
delete_on_termination:
type: bool
description: Whether the device should be automatically deleted when the Instance is terminated.
snapshot_id:
type: str
description: The ID of the Snapshot.
iops:
type: int
description: When using an C(io1) I(volume_type) this sets the number of IOPS provisioned for the volume
encrypted:
type: bool
description: Whether the volume should be encrypted.
volume_size:
aliases: ['size']
type: int
description: The size of the volume (in GiB)
volume_type:
type: str
description: The volume type. Defaults to C(gp2) when not set.
delete_on_termination:
type: bool
description: Whether the device should be automatically deleted when the Instance is terminated.
snapshot_id:
type: str
description: The ID of the Snapshot.
iops:
type: int
description: When using an C(io1) I(volume_type) this sets the number of IOPS provisioned for the volume.
encrypted:
type: bool
description: Whether the volume should be encrypted.
volume_size:
aliases: ['size']
type: int
description: The size of the volume (in GiB).
delete_snapshot:
description:
- Delete snapshots when deregistering the AMI.
default: false
type: bool
launch_permissions:
description:
- Users and groups that should be able to launch the AMI. Expects dictionary with a key of user_ids and/or group_names. user_ids should
be a list of account ids. group_name should be a list of groups, "all" is the only acceptable value currently.
- You must pass all desired launch permissions if you wish to modify existing launch permissions (passing just groups will remove all users)
- Users and groups that should be able to launch the AMI.
- Expects dictionary with a key of C(user_ids) and/or C(group_names).
- C(user_ids) should be a list of account IDs.
- C(group_name) should be a list of groups, C(all) is the only acceptable value currently.
- You must pass all desired launch permissions if you wish to modify existing launch permissions (passing just groups will remove all users).
type: dict
image_location:
description:
- The s3 location of an image to use for the AMI.
- The S3 location of an image to use for the AMI.
type: str
enhanced_networking:
description:
- A boolean representing whether enhanced networking with ENA is enabled or not.
type: bool
billing_products:
description:
- A list of valid billing codes. To be used with valid accounts by aws marketplace vendors.
- A list of valid billing codes. To be used with valid accounts by AWS Marketplace vendors.
type: list
elements: str
ramdisk_id:
Expand All @@ -149,7 +151,7 @@
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.tags.deprecated_purge
- amazon.aws.tags
'''

# Thank you to iAcquire for sponsoring development of this module.
Expand Down Expand Up @@ -726,7 +728,7 @@ def main():
ramdisk_id=dict(),
sriov_net_support=dict(),
tags=dict(type='dict', aliases=['resource_tags']),
purge_tags=dict(type='bool'),
purge_tags=dict(type='bool', default=True),
)

module = AnsibleAWSModule(
Expand All @@ -742,14 +744,6 @@ def main():
if not any([module.params['image_id'], module.params['name']]):
module.fail_json(msg="one of the following is required: name, image_id")

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='amazon.aws')
module.params['purge_tags'] = False

connection = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff())

if module.params.get('state') == 'absent':
Expand Down
Loading

0 comments on commit 86a1c1f

Please sign in to comment.