diff --git a/changelogs/fragments/916-purge_tags.yml b/changelogs/fragments/916-purge_tags.yml new file mode 100644 index 00000000000..c74d7468199 --- /dev/null +++ b/changelogs/fragments/916-purge_tags.yml @@ -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). diff --git a/plugins/modules/ec2_ami.py b/plugins/modules/ec2_ami.py index 85216ca077a..39979e3438b 100644 --- a/plugins/modules/ec2_ami.py +++ b/plugins/modules/ec2_ami.py @@ -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: @@ -76,39 +76,39 @@ 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. @@ -116,13 +116,15 @@ 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: @@ -130,7 +132,7 @@ 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: @@ -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. @@ -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( @@ -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': diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index 159e1be5aaa..b9791ff9759 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -13,8 +13,7 @@ short_description: Create & manage EC2 instances description: - Create and manage AWS EC2 instances. - - > - Note: This module does not support creating + - This module does not support creating L(EC2 Spot instances,https://aws.amazon.com/ec2/spot/). - The M(amazon.aws.ec2_spot_instance) module can create and manage spot instances. author: @@ -42,7 +41,7 @@ type: str wait: description: - - Whether or not to wait for the desired state (use wait_timeout to customize this). + - Whether or not to wait for the desired I(state) (use (wait_timeout) to customize this). default: true type: bool wait_timeout: @@ -52,9 +51,11 @@ type: int instance_type: description: - - Instance type to use for the instance, see U(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) - Only required when instance is not already present. - - If not specified, t2.micro will be used. + - Instance type to use for the instance, see U(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html). + - Only required when instance is not already present. + - If not specified, C(t2.micro) will be used. + - In a release after 2023-01-01 the default will be removed and either I(instance_type) or + I(launch_template) must be specificed when launching an instance. type: str count: description: @@ -73,7 +74,7 @@ version_added: 2.2.0 user_data: description: - - Opaque blob of data which is made available to the ec2 instance + - Opaque blob of data which is made available to the EC2 instance. type: str tower_callback: description: @@ -119,12 +120,14 @@ type: str security_groups: description: - - A list of security group IDs or names (strings). Mutually exclusive with I(security_group). + - A list of security group IDs or names (strings). + - Mutually exclusive with I(security_group). type: list elements: str security_group: description: - - A security group ID or name. Mutually exclusive with I(security_groups). + - A security group ID or name. + - Mutually exclusive with I(security_groups). type: str name: description: @@ -132,72 +135,72 @@ type: str vpc_subnet_id: description: - - The subnet ID in which to launch the instance (VPC) - If none is provided, M(amazon.aws.ec2_instance) will chose the default zone of the default VPC. + - The subnet ID in which to launch the instance (VPC). + - If none is provided, M(amazon.aws.ec2_instance) will chose the default zone of the default VPC. aliases: ['subnet_id'] type: str network: description: - - Either a dictionary containing the key 'interfaces' corresponding to a list of network interface IDs or + - Either a dictionary containing the key C(interfaces) corresponding to a list of network interface IDs or containing specifications for a single network interface. - Use the M(amazon.aws.ec2_eni) module to create ENIs with special settings. type: dict suboptions: interfaces: description: - - a list of ENI IDs (strings) or a list of objects containing the key I(id). + - A list of ENI IDs (strings) or a list of objects containing the key I(id). type: list elements: str assign_public_ip: description: - - when true assigns a public IP address to the interface + - When C(true) assigns a public IP address to the interface. type: bool private_ip_address: description: - - an IPv4 address to assign to the interface + - An IPv4 address to assign to the interface. type: str ipv6_addresses: description: - - a list of IPv6 addresses to assign to the network interface + - A list of IPv6 addresses to assign to the network interface. type: list elements: str source_dest_check: description: - - controls whether source/destination checking is enabled on the interface + - Controls whether source/destination checking is enabled on the interface. type: bool description: description: - - a description for the network interface + - A description for the network interface. type: str private_ip_addresses: description: - - a list of IPv4 addresses to assign to the network interface + - A list of IPv4 addresses to assign to the network interface. type: list elements: str subnet_id: description: - - the subnet to connect the network interface to + - The subnet to connect the network interface to. type: str delete_on_termination: description: - - Delete the interface when the instance it is attached to is - terminated. + - Delete the interface when the instance it is attached to is + terminated. type: bool device_index: description: - - The index of the interface to modify + - The index of the interface to modify. type: int groups: description: - - a list of security group IDs to attach to the interface + - A list of security group IDs to attach to the interface. type: list elements: str volumes: description: - - A list of block device mappings, by default this will always use the AMI root device so the volumes option is primarily for adding more storage. - - A mapping contains the (optional) keys device_name, virtual_name, ebs.volume_type, ebs.volume_size, ebs.kms_key_id, - ebs.snapshot_id, ebs.iops, and ebs.delete_on_termination. - - For more information about each parameter, see U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html). + - A list of block device mappings, by default this will always use the AMI root device so the volumes option is primarily for adding more storage. + - A mapping contains the (optional) keys C(device_name), C(virtual_name), C(ebs.volume_type), C(ebs.volume_size), C(ebs.kms_key_id), + C(ebs.snapshot_id), C(ebs.iops), and C(ebs.delete_on_termination). + - For more information about each parameter, see U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html). type: list elements: dict launch_template: @@ -207,23 +210,24 @@ suboptions: id: description: - - the ID of the launch template (optional if name is specified). + - The ID of the launch template (optional if name is specified). type: str name: description: - - the pretty name of the launch template (optional if id is specified). + - The pretty name of the launch template (optional if id is specified). type: str version: description: - - the specific version of the launch template to use. If unspecified, the template default is chosen. + - The specific version of the launch template to use. If unspecified, the template default is chosen. key_name: description: - - Name of the SSH access key to assign to the instance - must exist in the region the instance is created. + - Name of the SSH access key to assign to the instance - must exist in the region the instance is created. + - Use M(amazon.aws.ec2_key) to manage SSH keys. type: str availability_zone: description: - - Specify an availability zone to use the default subnet it. Useful if not specifying the I(vpc_subnet_id) parameter. - - If no subnet, ENI, or availability zone is provided, the default subnet in the default VPC will be used in the first AZ (alphabetically sorted). + - Specify an availability zone to use the default subnet it. Useful if not specifying the I(vpc_subnet_id) parameter. + - If no subnet, ENI, or availability zone is provided, the default subnet in the default VPC will be used in the first AZ (alphabetically sorted). type: str instance_initiated_shutdown_behavior: description: @@ -238,12 +242,12 @@ termination_protection: description: - Whether to enable termination protection. - This module will not terminate an instance with termination protection active, it must be turned off first. + - This module will not terminate an instance with termination protection active, it must be turned off first. type: bool cpu_credit_specification: description: - For T series instances, choose whether to allow increased charges to buy CPU credits if the default pool is depleted. - - Choose I(unlimited) to enable buying additional CPU credits. + - Choose C(unlimited) to enable buying additional CPU credits. choices: ['unlimited', 'standard'] type: str cpu_options: @@ -255,18 +259,18 @@ suboptions: threads_per_core: description: - - Select the number of threads per core to enable. Disable or Enable Intel HT. + - Select the number of threads per core to enable. Disable or Enable Intel HT. choices: [1, 2] required: true type: int core_count: description: - - Set the number of core to enable. + - Set the number of core to enable. required: true type: int detailed_monitoring: description: - - Whether to allow detailed cloudwatch metrics to be collected, enabling more detailed alerting. + - Whether to allow detailed CloudWatch metrics to be collected, enabling more detailed alerting. type: bool ebs_optimized: description: @@ -283,14 +287,14 @@ type: dict instance_role: description: - - The ARN or name of an EC2-enabled instance role to be used. If a name is not provided in arn format - then the ListInstanceProfiles permission must also be granted. - U(https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListInstanceProfiles.html) If no full ARN is provided, - the role with a matching name will be used from the active AWS account. + - The ARN or name of an EC2-enabled instance role to be used. + - If a name is not provided in ARN format then the ListInstanceProfiles permission must also be granted. + U(https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListInstanceProfiles.html) + - If no full ARN is provided, the role with a matching name will be used from the active AWS account. type: str placement_group: description: - - The placement group that needs to be assigned to the instance + - The placement group that needs to be assigned to the instance. type: str metadata_options: description: @@ -302,30 +306,30 @@ suboptions: http_endpoint: description: - - Enables or disables the HTTP metadata endpoint on instances. - - If specified a value of disabled, metadata of the instance will not be accessible. + - Enables or disables the HTTP metadata endpoint on instances. + - If specified a value of disabled, metadata of the instance will not be accessible. choices: [enabled, disabled] default: enabled type: str http_tokens: description: - - Set the state of token usage for instance metadata requests. - - If the state is optional (v1 and v2), instance metadata can be retrieved with or without a signed token header on request. - - If the state is required (v2), a signed token header must be sent with any instance metadata retrieval requests. + - Set the state of token usage for instance metadata requests. + - If the state is optional (v1 and v2), instance metadata can be retrieved with or without a signed token header on request. + - If the state is required (v2), a signed token header must be sent with any instance metadata retrieval requests. choices: [optional, required] default: optional type: str http_put_response_hop_limit: version_added: 4.0.0 type: int - description: > - The desired HTTP PUT response hop limit for instance metadata requests. - The larger the number, the further instance metadata requests can travel. + description: + - The desired HTTP PUT response hop limit for instance metadata requests. + - The larger the number, the further instance metadata requests can travel. default: 1 http_protocol_ipv6: version_added: 4.0.0 type: str - description: > + description: - Wether the instance metadata endpoint is available via IPv6 (C(enabled)) or not (C(disabled)). - Requires botocore >= 1.21.29 choices: [enabled, disabled] @@ -340,10 +344,9 @@ default: 'disabled' extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge - + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags ''' EXAMPLES = ''' @@ -2003,7 +2006,7 @@ def main(): instance_role=dict(type='str'), name=dict(type='str'), tags=dict(type='dict', aliases=['resource_tags']), - purge_tags=dict(type='bool'), + purge_tags=dict(type='bool', default=True), filters=dict(type='dict', default=None), launch_template=dict(type='dict'), key_name=dict(type='str'), @@ -2046,14 +2049,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='amazon.aws') - module.params['purge_tags'] = False - if not module.params.get('instance_type') and not module.params.get('launch_template') and module.params.get('state') != 'absent': module.deprecate("Default value instance_type has been deprecated, in the future you must set an instance_type or a launch_template", date='2023-01-01', collection_name='amazon.aws') diff --git a/plugins/modules/ec2_key.py b/plugins/modules/ec2_key.py index 3eb28ad103e..a471c987805 100644 --- a/plugins/modules/ec2_key.py +++ b/plugins/modules/ec2_key.py @@ -11,9 +11,9 @@ --- module: ec2_key version_added: 1.0.0 -short_description: Create or delete an ec2 key pair +short_description: Create or delete an EC2 key pair description: - - create or delete an ec2 key pair. + - Create or delete an EC2 key pair. options: name: description: @@ -33,7 +33,7 @@ type: bool state: description: - - create or delete keypair + - Create or delete keypair. required: false choices: [ present, absent ] default: 'present' @@ -52,11 +52,11 @@ - ed25519 version_added: 3.1.0 notes: -- Support for I(tags) and I(purge_tags) was added in release 2.1.0. + - Support for I(tags) and I(purge_tags) was added in release 2.1.0. extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags author: - "Vincent Viallet (@zbal)" @@ -66,7 +66,7 @@ EXAMPLES = ''' # Note: These examples do not set authentication details, see the AWS Guide for details. -- name: create a new ec2 key pair, returns generated private key +- name: create a new EC2 key pair, returns generated private key amazon.aws.ec2_key: name: my_keypair @@ -305,7 +305,7 @@ def main(): force=dict(type='bool', default=True), state=dict(default='present', choices=['present', 'absent']), tags=dict(type='dict', aliases=['resource_tags']), - purge_tags=dict(type='bool'), + purge_tags=dict(type='bool', default=True), key_type=dict(type='str', choices=['rsa', 'ed25519']), ) @@ -317,14 +317,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='amazon.aws') - module.params['purge_tags'] = False - ec2_client = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff()) name = module.params['name'] diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index 16bc4c7c006..71976978413 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -11,22 +11,23 @@ --- module: ec2_vol version_added: 1.0.0 -short_description: Create and attach a volume, return volume id and device map +short_description: Create and attach a volume, return volume ID and device map description: - - Creates an EBS volume and optionally attaches it to an instance. - - If both I(instance) and I(name) are given and the instance has a device at the device name, then no volume is created and no attachment is made. + - Creates an EBS volume and optionally attaches it to an instance. + - If both I(instance) and I(name) are given and the instance has a device at the device name, then no volume is created and no attachment is made. options: instance: description: - - Instance ID if you wish to attach the volume. Since 1.9 you can set to None to detach. + - Instance ID if you wish to attach the volume. + - Set to C(None) to detach the volume. type: str name: description: - - Volume Name tag if you wish to attach an existing volume (requires instance) + - Volume Name tag if you wish to attach an existing volume (requires instance). type: str id: description: - - Volume id if you wish to attach an existing volume (requires instance) or remove an existing volume + - Volume ID if you wish to attach an existing volume (requires instance) or remove an existing volume. type: str volume_size: description: @@ -34,9 +35,9 @@ type: int volume_type: description: - - Type of EBS volume; standard (magnetic), gp2 (SSD), gp3 (SSD), io1 (Provisioned IOPS), io2 (Provisioned IOPS), - st1 (Throughput Optimized HDD), sc1 (Cold HDD). - "Standard" is the old EBS default and continues to remain the Ansible default for backwards compatibility. + - Type of EBS volume; C(standard) (magnetic), C(gp2) (SSD), C(gp3) (SSD), C(io1) (Provisioned IOPS), C(io2) (Provisioned IOPS), + C(st1) (Throughput Optimized HDD), C(sc1) (Cold HDD). + - C(standard) is the old EBS default and continues to remain the Ansible default for backwards compatibility. default: standard choices: ['standard', 'gp2', 'io1', 'st1', 'sc1', 'gp3', 'io2'] type: str @@ -51,11 +52,11 @@ type: bool kms_key_id: description: - - Specify the id of the KMS key to use. + - Specify the ID of the KMS key to use. type: str device_name: description: - - Device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows. + - Device ID to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows. type: str delete_on_termination: description: @@ -75,8 +76,8 @@ description: - Whether to ensure the volume is present or absent. - I(state=list) was deprecated in release 1.1.0 and is no longer available - with release 4.0.0. The 'list' functionality has been moved to a dedicated - module M(amazon.aws.ec2_vol_info). + with release 4.0.0. + - The C(list) functionality has been moved to a dedicated module M(amazon.aws.ec2_vol_info). default: present choices: ['absent', 'present'] type: str @@ -95,7 +96,7 @@ version_added: 1.4.0 multi_attach: description: - - If set to C(yes), Multi-Attach will be enabled when creating the volume. + - If set to C(true), Multi-Attach will be enabled when creating the volume. - When you create a new volume, Multi-Attach is disabled by default. - This parameter is supported with io1 and io2 volumes only. type: bool @@ -106,13 +107,14 @@ - If set, allows to create volume in an Outpost. type: str version_added: 3.1.0 -author: "Lester Wade (@lwade)" +author: + - "Lester Wade (@lwade)" notes: -- Support for I(purge_tags) was added in release 1.5.0. + - Support for I(purge_tags) was added in release 1.5.0. extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags ''' EXAMPLES = ''' @@ -712,7 +714,7 @@ def main(): modify_volume=dict(default=False, type='bool'), throughput=dict(type='int'), outpost_arn=dict(type='str'), - purge_tags=dict(type='bool'), + purge_tags=dict(type='bool', default=True), multi_attach=dict(type='bool'), ) @@ -739,14 +741,6 @@ def main(): throughput = module.params.get('throughput') multi_attach = module.params.get('multi_attach') - 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 - # Ensure we have the zone or can get the zone if instance is None and zone is None and state == 'present': module.fail_json(msg="You must specify either instance or zone") diff --git a/plugins/modules/ec2_vpc_endpoint.py b/plugins/modules/ec2_vpc_endpoint.py index 14308d7d641..f8a744edea7 100644 --- a/plugins/modules/ec2_vpc_endpoint.py +++ b/plugins/modules/ec2_vpc_endpoint.py @@ -8,7 +8,7 @@ DOCUMENTATION = r''' module: ec2_vpc_endpoint -short_description: Create and delete AWS VPC Endpoints. +short_description: Create and delete AWS VPC endpoints version_added: 1.0.0 description: - Creates AWS VPC endpoints. @@ -46,14 +46,14 @@ version_added: 2.1.0 service: description: - - An AWS supported vpc endpoint service. Use the M(amazon.aws.ec2_vpc_endpoint_info) + - An AWS supported VPC endpoint service. Use the M(amazon.aws.ec2_vpc_endpoint_info) module to describe the supported endpoint services. - Required when creating an endpoint. required: false type: str policy: description: - - A properly formatted json policy as string, see + - A properly formatted JSON policy as string, see U(https://github.com/ansible/ansible/issues/7005#issuecomment-42894813). Cannot be used with I(policy_file). - Option when creating an endpoint. If not provided AWS will @@ -75,55 +75,57 @@ type: path state: description: - - present to ensure resource is created. - - absent to remove resource + - C(present) to ensure resource is created. + - C(absent) to remove resource. required: false default: present choices: [ "present", "absent" ] type: str wait: description: - - When specified, will wait for either available status for state present. - Unfortunately this is ignored for delete actions due to a difference in + - When specified, will wait for status to reach C(available) for I(state=present). + - Unfortunately this is ignored for delete actions due to a difference in behaviour from AWS. required: false default: no type: bool wait_timeout: description: - - Used in conjunction with wait. Number of seconds to wait for status. - Unfortunately this is ignored for delete actions due to a difference in + - Used in conjunction with I(wait). + - Number of seconds to wait for status. + - Unfortunately this is ignored for delete actions due to a difference in behaviour from AWS. required: false default: 320 type: int route_table_ids: description: - - List of one or more route table ids to attach to the endpoint. A route - is added to the route table with the destination of the endpoint if - provided. - - Route table ids are only valid for gateway type endpoints. + - List of one or more route table IDs to attach to the endpoint. + - A route is added to the route table with the destination of the + endpoint if provided. + - Route table IDs are only valid for C(Gateway) endpoints. required: false type: list elements: str vpc_endpoint_id: description: - - One or more vpc endpoint ids to remove from the AWS account + - One or more VPC endpoint IDs to remove from the AWS account. + - Required if I(state=absent). required: false type: str client_token: description: - - Optional client token to ensure idempotency + - Optional client token to ensure idempotency. required: false type: str -author: Karen Cheng (@Etherdaemon) +author: + - Karen Cheng (@Etherdaemon) notes: -- Support for I(tags) and I(purge_tags) was added in release 1.5.0. + - Support for I(tags) and I(purge_tags) was added in release 1.5.0. extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge - + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags ''' EXAMPLES = r''' @@ -426,7 +428,7 @@ def main(): vpc_endpoint_id=dict(), client_token=dict(no_log=False), 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, @@ -441,14 +443,6 @@ def main(): # Validate Requirements state = module.params.get('state') - 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 - if module.params.get('policy_file'): module.deprecate('The policy_file option has been deprecated and' ' will be removed after 2022-12-01', diff --git a/plugins/modules/ec2_vpc_net.py b/plugins/modules/ec2_vpc_net.py index 069b5bcb837..6143cce2511 100644 --- a/plugins/modules/ec2_vpc_net.py +++ b/plugins/modules/ec2_vpc_net.py @@ -10,9 +10,9 @@ --- module: ec2_vpc_net version_added: 1.0.0 -short_description: Configure AWS virtual private clouds +short_description: Configure AWS Virtual Private Clouds description: - - Create, modify, and terminate AWS virtual private clouds. + - Create, modify, and terminate AWS Virtual Private Clouds (VPCs). author: - Jonathan Davila (@defionscode) - Sloane Hertel (@s-hertel) @@ -81,15 +81,14 @@ type: str multi_ok: description: - - By default the module will not create another VPC if there is another VPC with the same name and CIDR block. Specify this as true if you want - duplicate VPCs created. + - By default the module will not create another VPC if there is another VPC with the same name and CIDR block. + Specify I(multi_ok=true) if you want duplicate VPCs created. type: bool default: false extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge - + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags ''' EXAMPLES = ''' @@ -620,7 +619,7 @@ def main(): dns_hostnames=dict(type='bool'), dhcp_opts_id=dict(), tags=dict(type='dict', aliases=['resource_tags']), - purge_tags=dict(type='bool', default=None), + purge_tags=dict(type='bool', default=True), state=dict(choices=['present', 'absent'], default='present'), multi_ok=dict(type='bool', default=False), purge_cidrs=dict(type='bool', default=False), @@ -636,14 +635,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='amazon.aws') - module.params['purge_tags'] = False - name = module.params.get('name') vpc_id = module.params.get('vpc_id') cidr_block = module.params.get('cidr_block') diff --git a/plugins/modules/ec2_vpc_route_table.py b/plugins/modules/ec2_vpc_route_table.py index 22b69369025..8a4c100f87b 100644 --- a/plugins/modules/ec2_vpc_route_table.py +++ b/plugins/modules/ec2_vpc_route_table.py @@ -10,18 +10,18 @@ --- module: ec2_vpc_route_table version_added: 1.0.0 -short_description: Manage route tables for AWS virtual private clouds +short_description: Manage route tables for AWS Virtual Private Clouds description: - - Manage route tables for AWS virtual private clouds + - Manage route tables for AWS Virtual Private Clouds (VPCs). author: -- Robert Estelle (@erydo) -- Rob White (@wimnat) -- Will Thames (@willthames) + - Robert Estelle (@erydo) + - Rob White (@wimnat) + - Will Thames (@willthames) options: gateway_id: description: - - The ID of the gateway to associate with the route table. - - If I(gateway_id) is C('None') or C(''), gateway will be disassociated with the route table. + - The ID of the gateway to associate with the route table. + - If I(gateway_id) is C('None') or C(''), gateway will be disassociated with the route table. type: str version_added: 3.2.0 lookup: @@ -45,23 +45,25 @@ type: bool default: True purge_subnets: - description: Purge existing subnets that are not found in subnets. Ignored unless the subnets option is supplied. + description: + - Purge existing subnets that are not found in subnets. + - Ignored unless the subnets option is supplied. default: True type: bool route_table_id: description: - - The ID of the route table to update or delete. - - Required when I(lookup=id). + - The ID of the route table to update or delete. + - Required when I(lookup=id). type: str routes: description: - - List of routes in the route table. - - Routes are specified as dicts containing the keys C(dest) and one of C(gateway_id), - C(instance_id), C(network_interface_id), or C(vpc_peering_connection_id). - - The value of C(dest) is used for the destination match. It may be a IPv4 CIDR block - or a IPv6 CIDR block. - - If I(gateway_id) is specified, you can refer to the VPC's IGW by using the value C(igw). - - Routes are required for present states. + - List of routes in the route table. + - Routes are specified as dicts containing the keys C(dest) and one of C(gateway_id), + C(instance_id), C(network_interface_id), or C(vpc_peering_connection_id). + - The value of C(dest) is used for the destination match. It may be a IPv4 CIDR block + or a IPv6 CIDR block. + - If I(gateway_id) is specified, you can refer to the VPC's IGW by using the value C(igw). + - Routes are required for present states. type: list elements: dict state: @@ -76,15 +78,15 @@ elements: str vpc_id: description: - - VPC ID of the VPC in which to create the route table. - - Required when I(state=present) or I(lookup=tag). + - VPC ID of the VPC in which to create the route table. + - Required when I(state=present) or I(lookup=tag). type: str notes: -- Tags are used to uniquely identify route tables within a VPC when the I(route_table_id) is not supplied. + - Tags are used to uniquely identify route tables within a VPC when the I(route_table_id) is not supplied. extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.tags.deprecated_purge + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.tags ''' EXAMPLES = r''' @@ -108,7 +110,7 @@ gateway_id: "{{ igw.gateway_id }}" register: public_route_table -- name: Create vpc gateway +- name: Create VPC gateway amazon.aws.ec2_vpc_igw: vpc_id: vpc-1245678 register: vpc_igw @@ -805,7 +807,7 @@ def main(): propagating_vgw_ids=dict(type='list', elements='str'), purge_routes=dict(default=True, type='bool'), purge_subnets=dict(default=True, type='bool'), - purge_tags=dict(type='bool'), + purge_tags=dict(type='bool', default=True), route_table_id=dict(), routes=dict(default=[], type='list', elements='dict'), state=dict(default='present', choices=['present', 'absent']), @@ -820,14 +822,6 @@ def main(): ['state', 'present', ['vpc_id']]], 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='amazon.aws') - module.params['purge_tags'] = False - # The tests for RouteTable existing uses its own decorator, we can safely # retry on InvalidRouteTableID.NotFound retry_decorator = AWSRetry.jittered_backoff(retries=10, catch_extra_error_codes=['InvalidRouteTableID.NotFound']) diff --git a/tests/integration/targets/ec2_ami/tasks/main.yml b/tests/integration/targets/ec2_ami/tasks/main.yml index 90280b97b82..d9a7770f50a 100644 --- a/tests/integration/targets/ec2_ami/tasks/main.yml +++ b/tests/integration/targets/ec2_ami/tasks/main.yml @@ -448,6 +448,7 @@ name: '{{ ec2_ami_name }}_ami' tags: New: Tag + purge_tags: no register: result - name: assert a tag was added @@ -464,7 +465,6 @@ name: '{{ ec2_ami_name }}_ami' tags: New: Tag - purge_tags: yes register: result - name: assert a tag was removed diff --git a/tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml b/tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml index a81e0040b42..2bde4b5895e 100644 --- a/tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml +++ b/tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml @@ -90,6 +90,7 @@ tags: TestId: "{{ ec2_instance_tag_TestId }}" Another: thing + purge_tags: false security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" instance_type: "{{ ec2_instance_type }}" @@ -109,7 +110,6 @@ state: present name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" - purge_tags: true tags: TestId: "{{ ec2_instance_tag_TestId }}" Another: thing diff --git a/tests/integration/targets/ec2_vol/tasks/main.yml b/tests/integration/targets/ec2_vol/tasks/main.yml index f4aa722ed0b..72bb5f60a0f 100644 --- a/tests/integration/targets/ec2_vol/tasks/main.yml +++ b/tests/integration/targets/ec2_vol/tasks/main.yml @@ -356,6 +356,7 @@ "Title Case": 'Hello Cruel World ❤️' CamelCase: 'SimpleCamelCase ❤️' snake_case: 'simple_snake_case ❤️' + purge_tags: false register: new_vol_attach_result - name: check task return attributes @@ -380,6 +381,41 @@ - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh' + - name: change some tag values + ec2_vol: + instance: "{{ test_instance.instance_ids[0] }}" + id: "{{ new_vol_attach_result.volume.id }}" + device_name: /dev/sdh + volume_size: 1 + volume_type: standard + tags: + "lowercase spaced": 'hello cruel world ❤️' + "Title Case": 'Hello Cruel World ❤️' + snake_case: 'simple_snake_case ❤️' + ResourcePrefix: "{{ resource_prefix }}" + purge_tags: true + register: new_vol_attach_result + + - name: check task return attributes + assert: + that: + - new_vol_attach_result.changed + - "'volume_id' in new_vol_attach_result" + - new_vol_attach_result.volume_id == "{{ new_vol_attach_result.volume_id }}" + - "'attachment_set' in new_vol_attach_result.volume" + - "'create_time' in new_vol_attach_result.volume" + - "'id' in new_vol_attach_result.volume" + - "'size' in new_vol_attach_result.volume" + - new_vol_attach_result.volume.size == 1 + - "'volume_type' in new_vol_attach_result" + - new_vol_attach_result.volume_type == 'standard' + - "'tags' in new_vol_attach_result.volume" + - (new_vol_attach_result.volume.tags | length) == 4 + - new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️' + - new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️' + - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' + - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix + - name: create a volume from a snapshot and attach to the instance (check_mode) ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" @@ -482,13 +518,11 @@ - changed_gp3_volume.volume.iops == 3000 # Ensure our tags are still here - "'tags' in changed_gp3_volume.volume" - - (changed_gp3_volume.volume.tags | length) == 6 + - (changed_gp3_volume.volume.tags | length) == 4 - new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️' - new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️' - - new_vol_attach_result.volume.tags["CamelCase"] == 'SimpleCamelCase ❤️' - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - - new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh' - name: volume must be from type gp3 (idempotent) ec2_vol: @@ -518,13 +552,11 @@ - changed_gp3_volume.volume.iops == 3000 - "'throughput' in changed_gp3_volume.volume" - "'tags' in changed_gp3_volume.volume" - - (changed_gp3_volume.volume.tags | length) == 6 + - (changed_gp3_volume.volume.tags | length) == 4 - new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️' - new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️' - - new_vol_attach_result.volume.tags["CamelCase"] == 'SimpleCamelCase ❤️' - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - - new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh' - name: re-read volume information to validate new volume_type ec2_vol_info: diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 087a21dd146..e69de29bb2d 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -1,7 +0,0 @@ -plugins/modules/ec2_ami.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_instance.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_key.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vol.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_endpoint.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_net.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_route_table.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 087a21dd146..e69de29bb2d 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -1,7 +0,0 @@ -plugins/modules/ec2_ami.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_instance.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_key.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vol.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_endpoint.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_net.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_route_table.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 087a21dd146..e69de29bb2d 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,7 +0,0 @@ -plugins/modules/ec2_ami.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_instance.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_key.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vol.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_endpoint.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_net.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0 -plugins/modules/ec2_vpc_route_table.py pylint:collection-deprecated-version # Deprecation planned for 5.0.0