From 7b447cfcffa723ca402df35b02ff7f56a6ba55fc Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 10 Jul 2022 07:26:18 +0000 Subject: [PATCH] ec2_vpc_vgw_info - update to not throw an error when run in check_mode (#1331) (#1336) [PR #1331/ed4165d6 backport][stable-4] ec2_vpc_vgw_info - update to not throw an error when run in check_mode This is a backport of PR #1331 as merged into main (ed4165d). SUMMARY fixes: #137 ec2_vpc_vgw_info currently throws an error when run in check_mode (it's using "DryRun") this unexpected and undocumented behaviour, and is the same practical effect as not supporting check_mode at all. ISSUE TYPE Feature Pull Request COMPONENT NAME plugins/modules/ec2_vpc_vgw_info.py ADDITIONAL INFORMATION Reviewed-by: Mark Chappell --- changelogs/fragments/137-ec2_vpc_vgw_info.yml | 2 ++ plugins/modules/ec2_vpc_vgw_info.py | 7 +++---- tests/integration/targets/ec2_vpc_vgw/tasks/main.yml | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/137-ec2_vpc_vgw_info.yml diff --git a/changelogs/fragments/137-ec2_vpc_vgw_info.yml b/changelogs/fragments/137-ec2_vpc_vgw_info.yml new file mode 100644 index 00000000000..69dd73ef778 --- /dev/null +++ b/changelogs/fragments/137-ec2_vpc_vgw_info.yml @@ -0,0 +1,2 @@ +minor_changes: +- ec2_vpc_vgw_info - updated to not throw an error when run in check_mode (https://github.com/ansible-collections/community.aws/issues/137). diff --git a/plugins/modules/ec2_vpc_vgw_info.py b/plugins/modules/ec2_vpc_vgw_info.py index a84b07bf589..5ddb04d2ae3 100644 --- a/plugins/modules/ec2_vpc_vgw_info.py +++ b/plugins/modules/ec2_vpc_vgw_info.py @@ -12,7 +12,7 @@ version_added: 1.0.0 short_description: Gather information about virtual gateways in AWS description: - - Gather information about virtual gateways in AWS. + - Gather information about virtual gateways (VGWs) in AWS. options: filters: description: @@ -21,7 +21,7 @@ type: dict vpn_gateway_ids: description: - - Get details of a specific Virtual Gateway ID. This value should be provided as a list. + - Get details of a specific Virtual Gateway ID. type: list elements: str author: @@ -151,7 +151,6 @@ def list_virtual_gateways(client, module): params = dict() params['Filters'] = ansible_dict_to_boto3_filter_list(module.params.get('filters')) - params['DryRun'] = module.check_mode if module.params.get("vpn_gateway_ids"): params['VpnGatewayIds'] = module.params.get("vpn_gateway_ids") @@ -168,7 +167,7 @@ def list_virtual_gateways(client, module): def main(): argument_spec = dict( filters=dict(type='dict', default=dict()), - vpn_gateway_ids=dict(type='list', default=None, elements='str') + vpn_gateway_ids=dict(type='list', default=None, elements='str'), ) module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml index ba67e4b426f..0a6f9bacdb7 100644 --- a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml @@ -76,10 +76,11 @@ # ============================================================ - - name: get VPC VGW facts by ID + - name: get VPC VGW facts by ID (CHECK) ec2_vpc_vgw_info: vpn_gateway_ids: ['{{ vgw_id }}'] register: vgw_info + check_mode: True - name: verify expected facts vars: