From 4e8bb334a9da287bb31775db2e7f4e7318ec90ca Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 30 Oct 2019 22:28:14 +0100 Subject: [PATCH] Sanity test fixups: AWS VPC related modules (#64089) * Add missing boilerplate * Avoid blocklisted variable name '_' * doc fixups * Remove defaults for required parameters * Remove explicit definition of 'region' from argument spec it's automatically added by ec2_argument_spec and redefining removes the aliases * remove sanity ignore entries for AWS VPC related modules * Suggested Review changes --- .../cloud/amazon/ec2_vpc_dhcp_option.py | 12 ++++ .../cloud/amazon/ec2_vpc_dhcp_option_info.py | 13 ++++- .../cloud/amazon/ec2_vpc_egress_igw.py | 7 ++- .../modules/cloud/amazon/ec2_vpc_endpoint.py | 10 ++++ .../cloud/amazon/ec2_vpc_endpoint_info.py | 7 ++- .../modules/cloud/amazon/ec2_vpc_igw.py | 3 + .../modules/cloud/amazon/ec2_vpc_igw_info.py | 3 + .../cloud/amazon/ec2_vpc_nat_gateway.py | 31 ++++++---- .../cloud/amazon/ec2_vpc_nat_gateway_info.py | 5 +- .../modules/cloud/amazon/ec2_vpc_net.py | 13 ++++- .../modules/cloud/amazon/ec2_vpc_net_info.py | 19 +++---- .../modules/cloud/amazon/ec2_vpc_peer.py | 7 +++ .../cloud/amazon/ec2_vpc_peering_info.py | 5 +- .../cloud/amazon/ec2_vpc_route_table.py | 27 +++++---- .../cloud/amazon/ec2_vpc_route_table_info.py | 1 + .../modules/cloud/amazon/ec2_vpc_subnet.py | 17 ++++-- .../cloud/amazon/ec2_vpc_subnet_info.py | 21 +++---- .../modules/cloud/amazon/ec2_vpc_vgw.py | 10 +++- .../modules/cloud/amazon/ec2_vpc_vgw_info.py | 3 + .../modules/cloud/amazon/ec2_vpc_vpn.py | 25 +++++++- .../modules/cloud/amazon/ec2_vpc_vpn_info.py | 6 ++ test/sanity/ignore.txt | 57 ------------------- .../cloud/amazon/test_ec2_vpc_nat_gateway.py | 15 +++-- .../modules/cloud/amazon/test_ec2_vpc_vpn.py | 25 +++----- 24 files changed, 195 insertions(+), 147 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option.py index 75b6673ac94..2e244344899 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option.py @@ -35,26 +35,35 @@ options: domain_name: description: - The domain name to set in the DHCP option sets + type: str dns_servers: description: - A list of hosts to set the DNS servers for the VPC to. (Should be a list of IP addresses rather than host names.) + type: list + elements: str ntp_servers: description: - List of hosts to advertise as NTP servers for the VPC. + type: list + elements: str netbios_name_servers: description: - List of hosts to advertise as NetBIOS servers. + type: list + elements: str netbios_node_type: description: - NetBIOS node type to advertise in the DHCP options. The AWS recommendation is to use 2 (when using netbios name services) U(https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html) + type: int vpc_id: description: - VPC ID to associate with the requested DHCP option set. If no vpc id is provided, and no matching option set is found then a new DHCP option set is created. + type: str delete_old: description: - Whether to delete the old VPC DHCP option set when associating a new one. @@ -77,12 +86,14 @@ options: if the resource_id is provided. (options must match) aliases: [ 'resource_tags'] version_added: "2.1" + type: dict dhcp_options_id: description: - The resource_id of an existing DHCP options set. If this is specified, then it will override other settings, except tags (which will be updated to match) version_added: "2.1" + type: str state: description: - create/assign or remove the DHCP options. @@ -91,6 +102,7 @@ options: default: present choices: [ 'absent', 'present' ] version_added: "2.1" + type: str extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py index 976567045cc..ac909fb1a95 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py @@ -26,11 +26,20 @@ options: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeDhcpOptions.html) for possible filters. + type: dict dhcp_options_ids: description: - - Get details of specific DHCP Option ID - - Provide this value as a list + - Get details of specific DHCP Option IDs. aliases: ['DhcpOptionIds'] + type: list + elements: str + dry_run: + description: + - Checks whether you have the required permissions to view the DHCP + Options. + aliases: ['DryRun'] + version_added: "2.4" + type: bool extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py index 6558a9a71b8..3224cc8f650 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py @@ -2,6 +2,9 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} @@ -20,11 +23,13 @@ options: description: - The VPC ID for the VPC that this Egress Only Internet Gateway should be attached. required: true + type: str state: description: - - Create or delete the EIGW + - Create or delete the EIGW. default: present choices: [ 'present', 'absent' ] + type: str extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py index e154676de53..9fcb82d5b46 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py @@ -25,12 +25,14 @@ options: description: - Required when creating a VPC endpoint. required: false + type: str service: description: - An AWS supported vpc endpoint service. Use the M(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 @@ -39,6 +41,7 @@ options: - Option when creating an endpoint. If not provided AWS will utilise a default policy which provides full access to the service. required: false + type: json policy_file: description: - The path to the properly json formatted policy file, see @@ -48,6 +51,7 @@ options: utilise a default policy which provides full access to the service. required: false aliases: [ "policy_path" ] + type: path state: description: - present to ensure resource is created. @@ -55,6 +59,7 @@ options: required: false default: present choices: [ "present", "absent"] + type: str wait: description: - When specified, will wait for either available status for state present. @@ -70,20 +75,25 @@ options: 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. required: false + type: list + elements: str vpc_endpoint_id: description: - One or more vpc endpoint ids to remove from the AWS account required: false + type: str client_token: description: - Optional client token to ensure idempotency required: false + type: str author: Karen Cheng (@Etherdaemon) extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py index 67da79f8543..9f1c8f261f7 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py @@ -13,7 +13,7 @@ DOCUMENTATION = ''' module: ec2_vpc_endpoint_info short_description: Retrieves AWS VPC endpoints details using AWS methods. description: - - Gets various details related to AWS VPC Endpoints + - Gets various details related to AWS VPC Endpoints. - This module was called C(ec2_vpc_endpoint_facts) before Ansible 2.9. The usage did not change. version_added: "2.4" requirements: [ boto3 ] @@ -26,15 +26,18 @@ options: choices: - services - endpoints + type: str vpc_endpoint_ids: description: - Get details of specific endpoint IDs - - Provide this value as a list + type: list + elements: str filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpoints.html) for possible filters. + type: dict author: Karen Cheng (@Etherdaemon) extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py index d032d07259d..a7145b0646d 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py @@ -24,16 +24,19 @@ options: description: - The VPC ID for the VPC in which to manage the Internet Gateway. required: true + type: str tags: description: - "A dict of tags to apply to the internet gateway. Any tags currently applied to the internet gateway and not present here will be removed." aliases: [ 'resource_tags' ] version_added: "2.4" + type: dict state: description: - Create or terminate the IGW default: present choices: [ 'present', 'absent' ] + type: str extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_info.py index ec9d2ad1529..11ee974ae5f 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_igw_info.py @@ -26,9 +26,12 @@ options: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInternetGateways.html) for possible filters. + type: dict internet_gateway_ids: description: - Get details of specific Internet Gateway ID. Provide this value as a list. + type: list + elements: str extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py index 2b38b0941b6..7598b232666 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py @@ -25,23 +25,28 @@ options: - Ensure NAT Gateway is present or absent. default: "present" choices: ["present", "absent"] + type: str nat_gateway_id: description: - The id AWS dynamically allocates to the NAT Gateway on creation. This is required when the absent option is present. + type: str subnet_id: description: - The id of the subnet to create the NAT Gateway in. This is required with the present option. + type: str allocation_id: description: - The id of the elastic IP allocation. If this is not passed and the eip_address is not passed. An EIP is generated for this NAT Gateway. + type: str eip_address: description: - The elastic IP address of the EIP you want attached to this NAT Gateway. If this is not passed and the allocation_id is not passed, an EIP is generated for this NAT Gateway. + type: str if_exist_do_not_create: description: - if a NAT Gateway exists already in the subnet_id, then do not create a new one. @@ -53,22 +58,24 @@ options: - Deallocate the EIP from the VPC. - Option is only valid with the absent state. - You should use this with the wait option. Since you can not release an address while a delete operation is happening. - default: 'yes' + default: false type: bool wait: description: - Wait for operation to complete before returning. - default: 'no' + default: false type: bool wait_timeout: description: - How many seconds to wait for an operation to complete before timing out. - default: 300 + default: 320 + type: int client_token: description: - Optional unique token to be used during create to ensure idempotency. When specifying this option, ensure you specify the eip_address parameter as well otherwise any subsequent runs will fail. + type: str author: - Allen Sanabria (@linuxdynasty) - Jon Hadfield (@jonhadfield) @@ -103,7 +110,7 @@ EXAMPLES = ''' state: present subnet_id: subnet-12345678 eip_address: 52.1.1.1 - wait: yes + wait: true region: ap-southeast-2 register: new_nat_gateway @@ -111,7 +118,7 @@ EXAMPLES = ''' ec2_vpc_nat_gateway: state: present subnet_id: subnet-12345678 - wait: yes + wait: true region: ap-southeast-2 register: new_nat_gateway @@ -119,7 +126,7 @@ EXAMPLES = ''' ec2_vpc_nat_gateway: state: present subnet_id: subnet-12345678 - wait: yes + wait: true region: ap-southeast-2 if_exist_do_not_create: true register: new_nat_gateway @@ -128,9 +135,9 @@ EXAMPLES = ''' ec2_vpc_nat_gateway: state: absent region: ap-southeast-2 - wait: yes + wait: true nat_gateway_id: "{{ item.NatGatewayId }}" - release_eip: yes + release_eip: true register: delete_nat_gateway_result loop: "{{ gateways_to_remove.result }}" @@ -138,7 +145,7 @@ EXAMPLES = ''' ec2_vpc_nat_gateway: state: absent nat_gateway_id: nat-12345678 - wait: yes + wait: true wait_timeout: 500 region: ap-southeast-2 @@ -146,7 +153,7 @@ EXAMPLES = ''' ec2_vpc_nat_gateway: state: absent nat_gateway_id: nat-12345678 - release_eip: yes + release_eip: true wait: yes wait_timeout: 300 region: ap-southeast-2 @@ -447,7 +454,7 @@ def gateway_in_subnet_exists(client, subnet_id, allocation_id=None, allocation_id_exists = False gateways = [] states = ['available', 'pending'] - gws_retrieved, _, gws = ( + gws_retrieved, err_msg, gws = ( get_nat_gateways( client, subnet_id, states=states, check_mode=check_mode ) @@ -874,7 +881,7 @@ def remove(client, nat_gateway_id, wait=False, wait_timeout=0, results = list() states = ['pending', 'available'] try: - exist, _, gw = ( + exist, err_msg, gw = ( get_nat_gateways( client, nat_gateway_id=nat_gateway_id, states=states, check_mode=check_mode diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_info.py index 15e02c2b5dc..6ecb27b5889 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_info.py @@ -22,12 +22,15 @@ requirements: [ boto3 ] options: nat_gateway_ids: description: - - Get details of specific nat gateway IDs + - List of specific nat gateway IDs to fetch details for. + type: list + elements: str filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNatGateways.html) for possible filters. + type: dict author: Karen Cheng (@Etherdaemon) extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_net.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_net.py index cc97d4a7f38..5cd49ccb126 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_net.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_net.py @@ -26,11 +26,14 @@ options: description: - The name to give your VPC. This is used in combination with C(cidr_block) to determine if a VPC already exists. required: yes + type: str cidr_block: description: - The primary CIDR of the VPC. After 2.5 a list of CIDRs can be provided. The first in the list will be used as the primary CIDR and is used in conjunction with the C(name) to ensure idempotence. required: yes + type: list + elements: str ipv6_cidr: description: - Request an Amazon-provided IPv6 CIDR block with /56 prefix length. You cannot specify the range of IPv6 addresses, @@ -49,6 +52,7 @@ options: - Whether to be default or dedicated tenancy. This cannot be changed after the VPC has been created. default: default choices: [ 'default', 'dedicated' ] + type: str dns_support: description: - Whether to enable AWS DNS support. @@ -61,17 +65,20 @@ options: type: bool dhcp_opts_id: description: - - the id of the DHCP options to use for this vpc + - The id of the DHCP options to use for this VPC. + type: str tags: description: - The tags you want attached to the VPC. This is independent of the name value, note if you pass a 'Name' key it would override the Name of the VPC if it's different. aliases: [ 'resource_tags' ] + type: dict state: description: - The state of the VPC. Either absent or present. default: present choices: [ 'present', 'absent' ] + 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 @@ -136,8 +143,8 @@ vpc: classic_link_enabled: description: indicates whether ClassicLink is enabled returned: always - type: NoneType - sample: null + type: bool + sample: false dhcp_options_id: description: the id of the DHCP options associated with this VPC returned: always diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py index a4ab04aa0a5..b38fda534ba 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py @@ -1,17 +1,9 @@ #!/usr/bin/python # -# This is a free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This Ansible library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this library. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], @@ -35,10 +27,13 @@ options: description: - A list of VPC IDs that exist in your account. version_added: "2.5" + type: list + elements: str filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html) for possible filters. + type: dict extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py index 4cf9edbe2f3..fff0a975284 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py @@ -23,33 +23,40 @@ options: description: - VPC id of the requesting VPC. required: false + type: str peering_id: description: - Peering connection id. required: false + type: str peer_region: description: - Region of the accepting VPC. required: false version_added: '2.5' + type: str peer_vpc_id: description: - VPC id of the accepting VPC. required: false + type: str peer_owner_id: description: - The AWS account number for cross account peering. required: false + type: str tags: description: - Dictionary of tags to look for and apply when creating a Peering Connection. required: false + type: dict state: description: - Create, delete, accept, reject a peering connection. required: false default: present choices: ['present', 'absent', 'accept', 'reject'] + type: str author: Mike Mochan (@mmochan) extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_peering_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_peering_info.py index 414e8900ec9..13a22a3e3a9 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_peering_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_peering_info.py @@ -21,12 +21,15 @@ requirements: [ boto3 ] options: peer_connection_ids: description: - - Get details of specific vpc peer IDs + - List of specific VPC peer IDs to get details for. + type: list + elements: str filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcPeeringConnections.html) for possible filters. + type: dict author: Karen Cheng (@Etherdaemon) extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py index 9a49af2e689..0530d526afa 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py @@ -1,17 +1,9 @@ #!/usr/bin/python # -# This is a free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This Ansible library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this library. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], @@ -36,8 +28,11 @@ options: route table will be created. To change tags of a route table you must look up by id. default: tag choices: [ 'tag', 'id' ] + type: str propagating_vgw_ids: description: Enable route propagation from virtual gateways specified by ID. + type: list + elements: str purge_routes: version_added: "2.3" description: Purge existing routes that are not found in routes. @@ -55,27 +50,35 @@ options: default: 'no' route_table_id: description: The ID of the route table to update or delete. + type: str routes: description: List of routes in the route table. Routes are specified as dicts containing the keys 'dest' and one of 'gateway_id', 'instance_id', 'network_interface_id', or 'vpc_peering_connection_id'. If 'gateway_id' is specified, you can refer to the VPC's IGW by using the value 'igw'. Routes are required for present states. + type: list + elements: str state: description: Create or destroy the VPC route table default: present choices: [ 'present', 'absent' ] + type: str subnets: description: An array of subnets to add to this route table. Subnets may be specified by either subnet ID, Name tag, or by a CIDR such as '10.0.0.0/24'. + type: list + elements: str tags: description: > A dictionary of resource tags of the form: { tag1: value1, tag2: value2 }. Tags are used to uniquely identify route tables within a VPC when the route_table_id is not supplied. aliases: [ "resource_tags" ] + type: dict vpc_id: description: VPC ID of the VPC in which to create the route table. required: true + type: str extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_info.py index 652e7ec3384..c3b40046084 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_info.py @@ -25,6 +25,7 @@ options: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html) for possible filters. + type: dict extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py index 5f3d23ec2c3..d613deece00 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py @@ -26,27 +26,33 @@ options: az: description: - "The availability zone for the subnet." + type: str cidr: description: - "The CIDR block for the subnet. E.g. 192.0.2.0/24." + type: str ipv6_cidr: description: - "The IPv6 CIDR block for the subnet. The VPC must have a /56 block assigned and this value must be a valid IPv6 /64 that falls in the VPC range." - "Required if I(assign_instances_ipv6=true)" version_added: "2.5" + type: str tags: description: - "A dict of tags to apply to the subnet. Any tags currently applied to the subnet and not present here will be removed." aliases: [ 'resource_tags' ] + type: dict state: description: - "Create or remove the subnet" default: present choices: [ 'present', 'absent' ] + type: str vpc_id: description: - "VPC ID of the VPC in which to create or delete the subnet." required: true + type: str map_public: description: - "Specify C(yes) to indicate that instances launched into the subnet should be assigned public IP address by default." @@ -57,24 +63,25 @@ options: description: - "Specify C(yes) to indicate that instances launched into the subnet should be automatically assigned an IPv6 address." type: bool - default: 'no' + default: false version_added: "2.5" wait: description: - "When specified,I(state=present) module will wait for subnet to be in available state before continuing." type: bool - default: 'yes' + default: true version_added: "2.5" wait_timeout: description: - "Number of seconds to wait for subnet to become available I(wait=True)." default: 300 version_added: "2.5" + type: int purge_tags: description: - Whether or not to remove tags that do not appear in the I(tags) list. type: bool - default: 'yes' + default: true version_added: "2.5" extends_documentation_fragment: - aws @@ -559,11 +566,11 @@ def main(): argument_spec.update( dict( az=dict(default=None, required=False), - cidr=dict(default=None, required=True), + cidr=dict(required=True), ipv6_cidr=dict(default='', required=False), state=dict(default='present', choices=['present', 'absent']), tags=dict(default={}, required=False, type='dict', aliases=['resource_tags']), - vpc_id=dict(default=None, required=True), + vpc_id=dict(required=True), map_public=dict(default=False, required=False, type='bool'), assign_instances_ipv6=dict(default=False, required=False, type='bool'), wait=dict(type='bool', default=True), diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py index 73b587c64aa..d582e31f3d6 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py @@ -1,17 +1,9 @@ #!/usr/bin/python # -# This is a free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This Ansible library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this library. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], @@ -35,11 +27,14 @@ options: description: - A list of subnet IDs to gather information for. version_added: "2.5" - aliases: [subnet_id] + aliases: ['subnet_id'] + type: list + elements: str filters: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html) for possible filters. + type: dict extends_documentation_fragment: - aws - ec2 diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py index 7b4eb80012c..6bcc007c7f6 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py @@ -28,31 +28,40 @@ options: - absent to remove resource default: present choices: [ "present", "absent"] + type: str name: description: - name of the vgw to be created or deleted + type: str type: description: - type of the virtual gateway to be created choices: [ "ipsec.1" ] + default: "ipsec.1" + type: str vpn_gateway_id: description: - vpn gateway id of an existing virtual gateway + type: str vpc_id: description: - the vpc-id of a vpc to attach or detach + type: str asn: description: - the BGP ASN of the amazon side version_added: "2.6" + type: int wait_timeout: description: - number of seconds to wait for status during vpc attach and detach default: 320 + type: int tags: description: - dictionary of resource tags aliases: [ "resource_tags" ] + type: dict author: Nick Aslanidis (@naslanidis) extends_documentation_fragment: - ec2 @@ -538,7 +547,6 @@ def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( state=dict(default='present', choices=['present', 'absent']), - region=dict(required=True), name=dict(), vpn_gateway_id=dict(), vpc_id=dict(), diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_info.py index e72833683f6..57e20e2cda2 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_info.py @@ -25,9 +25,12 @@ options: description: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html) for possible filters. + type: dict vpn_gateway_ids: description: - Get details of a specific Virtual Gateway ID. This value should be provided as a list. + type: list + elements: str author: "Nick Aslanidis (@naslanidis)" extends_documentation_fragment: - aws diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py index c1e6cedb3d9..29d65326ffb 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py @@ -2,6 +2,9 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} @@ -27,23 +30,29 @@ options: choices: ['present', 'absent'] default: present required: no + type: str customer_gateway_id: description: - The ID of the customer gateway. + type: str connection_type: description: - The type of VPN connection. - choices: ['ipsec.1'] + - At this time only 'ipsec.1' is supported. default: ipsec.1 + type: str vpn_gateway_id: description: - The ID of the virtual private gateway. + type: str vpn_connection_id: description: - The ID of the VPN connection. Required to modify or delete a connection if the filters option does not provide a unique match. + type: str tags: description: - Tags to attach to the VPN connection. + type: dict purge_tags: description: - Whether or not to delete VPN connections tags that are associated with the connection but not specified in the task. @@ -62,6 +71,15 @@ options: the aforementioned keys. required: no version_added: "2.5" + type: list + elements: dict + suboptions: + TunnelInsideCidr: + type: str + description: The range of inside IP addresses for the tunnel. + PreSharedKey: + type: str + description: The pre-shared key (PSK) to establish initial authentication between the virtual private gateway and customer gateway. filters: description: - An alternative to using vpn_connection_id. If multiple matches are found, vpn_connection_id is required. @@ -103,9 +121,12 @@ options: cgw: description: - The customer gateway id as a string or a list of those strings. + type: dict routes: description: - Routes to add to the connection. + type: list + elements: str purge_routes: description: - Whether or not to delete VPN connections routes that are not specified in the task. @@ -690,7 +711,7 @@ def ensure_present(connection, module_params, check_mode=False): max_attempts=max_attempts, delay=delay) changes = check_for_update(connection, module_params, vpn_connection['VpnConnectionId']) - _ = make_changes(connection, vpn_connection['VpnConnectionId'], changes) + make_changes(connection, vpn_connection['VpnConnectionId'], changes) # get latest version if a change has been made and make tags output nice before returning it if vpn_connection: diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py index 1a61eb10e6b..862b07ecc83 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py @@ -2,6 +2,9 @@ # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', @@ -24,10 +27,13 @@ options: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpnConnections.html) for possible filters. required: false + type: dict vpn_connection_ids: description: - Get details of a specific VPN connections using vpn connection ID/IDs. This value should be provided as a list. required: false + type: list + elements: str extends_documentation_fragment: - aws - ec2 diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index e1f250adc20..6d5fb6ad74d 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -641,57 +641,6 @@ lib/ansible/modules/cloud/amazon/ec2_vol.py validate-modules:doc-choices-do-not- lib/ansible/modules/cloud/amazon/ec2_vol.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/cloud/amazon/ec2_vol.py validate-modules:doc-missing-type lib/ansible/modules/cloud/amazon/ec2_vol_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py validate-modules:undocumented-parameter -lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_option_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_egress_igw.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_endpoint_info.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_igw.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_igw_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py pylint:blacklisted-name -lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_net.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_net.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_net.py validate-modules:return-syntax-error -lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_net_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_peering_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py validate-modules:no-default-for-required-parameter -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py validate-modules:nonexistent-parameter-documented -lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py validate-modules:doc-missing-type -lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_info.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py pylint:blacklisted-name -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py future-import-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py metaclass-boilerplate -lib/ansible/modules/cloud/amazon/ec2_vpc_vpn_info.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/cloud/amazon/ec2_win_password.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/cloud/amazon/ec2_win_password.py validate-modules:doc-missing-type lib/ansible/modules/cloud/amazon/ecs_attribute.py validate-modules:parameter-type-not-in-doc @@ -5893,12 +5842,6 @@ test/units/module_utils/xenserver/FakeAnsibleModule.py future-import-boilerplate test/units/module_utils/xenserver/FakeAnsibleModule.py metaclass-boilerplate test/units/module_utils/xenserver/FakeXenAPI.py future-import-boilerplate test/units/module_utils/xenserver/FakeXenAPI.py metaclass-boilerplate -test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py future-import-boilerplate -test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py metaclass-boilerplate -test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py pylint:blacklisted-name -test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py future-import-boilerplate -test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py metaclass-boilerplate -test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py pylint:blacklisted-name test/units/modules/cloud/google/test_gce_tag.py future-import-boilerplate test/units/modules/cloud/google/test_gce_tag.py metaclass-boilerplate test/units/modules/cloud/google/test_gcp_forwarding_rule.py future-import-boilerplate diff --git a/test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py index 74e8e4d0953..53cd8c4c2cc 100644 --- a/test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py +++ b/test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py @@ -1,3 +1,8 @@ +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import pytest import unittest @@ -85,7 +90,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_get_eip_allocation_id_by_address(self): client = boto3.client('ec2', region_name=aws_region) - allocation_id, _ = ( + allocation_id, error_msg = ( ng.get_eip_allocation_id_by_address( client, '55.55.55.55', check_mode=True ) @@ -114,7 +119,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_release_address(self): client = boto3.client('ec2', region_name=aws_region) - success, _ = ( + success, err_msg = ( ng.release_address( client, 'eipalloc-1234567', check_mode=True ) @@ -173,7 +178,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_delete(self): client = boto3.client('ec2', region_name=aws_region) - success, changed, err_msg, _ = ( + success, changed, err_msg, results = ( ng.remove( client, 'nat-123456789', check_mode=True ) @@ -183,7 +188,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_delete_and_release_ip(self): client = boto3.client('ec2', region_name=aws_region) - success, changed, err_msg, _ = ( + success, changed, err_msg, results = ( ng.remove( client, 'nat-123456789', release_eip=True, check_mode=True ) @@ -193,7 +198,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_delete_if_does_not_exist(self): client = boto3.client('ec2', region_name=aws_region) - success, changed, err_msg, _ = ( + success, changed, err_msg, results = ( ng.remove( client, 'nat-12345', check_mode=True ) diff --git a/test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py b/test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py index 13b81de1a66..5bf3b40f918 100644 --- a/test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py +++ b/test/units/modules/cloud/amazon/test_ec2_vpc_vpn.py @@ -1,19 +1,8 @@ # (c) 2017 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import pytest import os @@ -165,8 +154,8 @@ def test_find_connection_insufficient_filters(placeboify, maybe_sleep): params2 = make_params(cgw[1], vgw[1], tags={'Correct': 'Tag'}) m, conn = setup_mod_conn(placeboify, params) m2, conn2 = setup_mod_conn(placeboify, params2) - _, vpn1 = ec2_vpc_vpn.ensure_present(conn, m.params) - _, vpn2 = ec2_vpc_vpn.ensure_present(conn2, m2.params) + vpn1 = ec2_vpc_vpn.ensure_present(conn, m.params)[1] + vpn2 = ec2_vpc_vpn.ensure_present(conn2, m2.params)[1] # reset the parameters so only filtering by tags will occur m.params = {'filters': {'tags': {'Correct': 'Tag'}}} @@ -354,7 +343,7 @@ def setup_req(placeboify, number_of_results=1): for each in range(0, number_of_results): params = make_params(cgw[each], vgw[each]) m, conn = setup_mod_conn(placeboify, params) - _, vpn = ec2_vpc_vpn.ensure_present(conn, params) + vpn = ec2_vpc_vpn.ensure_present(conn, params)[1] results.append({'module': m, 'connection': conn, 'vpn': vpn, 'params': params}) if number_of_results == 1: