Fixed argument spec for multiple modules - Part II (#65497)

This change contains fixes for argument spec and respective datatypes.
Created separate PR since these changes might alter the behavior of these modules.
Will need shipit from individual module owner(s).

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2020-01-21 11:37:38 +05:30 committed by GitHub
parent 04b60624ef
commit 14ae3ba8c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 55 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Fixes argument spec for several modules for using correct datatypes.

View file

@ -30,6 +30,7 @@ options:
name:
description:
- The name of the GCE instance template.
required: True
size:
description:
- The desired machine type for the instance template.
@ -530,7 +531,7 @@ def main():
module = AnsibleModule(
argument_spec=dict(
state=dict(choices=['present', 'absent'], default='present'),
name=dict(require=True, aliases=['base_name']),
name=dict(required=True, aliases=['base_name']),
size=dict(default='f1-micro'),
source=dict(),
image=dict(),
@ -571,7 +572,7 @@ def main():
try:
gce = gce_connect(module)
except GoogleBaseError as e:
module.fail_json(msg='GCE Connexion failed %s' % to_native(e), exception=traceback.format_exc())
module.fail_json(msg='GCE Connection failed %s' % to_native(e), exception=traceback.format_exc())
if module.check_mode:
(changed, output) = check_if_system_state_would_be_changed(module, gce)

View file

@ -234,8 +234,8 @@ def main():
allocation_pool_start=dict(type='str'),
allocation_pool_end=dict(type='str'),
host_routes=dict(type='list', default=None),
ipv6_ra_mode=dict(type='str', choice=ipv6_mode_choices),
ipv6_address_mode=dict(type='str', choice=ipv6_mode_choices),
ipv6_ra_mode=dict(type='str', choices=ipv6_mode_choices),
ipv6_address_mode=dict(type='str', choices=ipv6_mode_choices),
use_default_subnetpool=dict(type='bool', default=False),
extra_specs=dict(type='dict', default=dict()),
state=dict(type='str', default='present', choices=['absent', 'present']),

View file

@ -160,7 +160,7 @@ def _wait(timeout, cloud, zone, state, module, sdk):
def main():
argument_spec = openstack_full_argument_spec(
name=dict(required=True),
zone_type=dict(required=False, choice=['primary', 'secondary']),
zone_type=dict(required=False, choices=['primary', 'secondary']),
email=dict(required=False, default=None),
description=dict(required=False, default=None),
ttl=dict(required=False, default=None, type='int'),

View file

@ -241,7 +241,7 @@ def main():
interface=dict(type='str'),
description=dict(type='str'),
admin_distance=dict(type='str', default='1'),
tag=dict(tag='str'),
tag=dict(type='str'),
state=dict(default='present', choices=['present', 'absent'])
)

View file

@ -263,7 +263,7 @@ def main():
name=dict(type='str', aliases=['description']),
admin_distance=dict(type='str'),
track=dict(type='str'),
tag=dict(tag='str'),
tag=dict(type='str'),
state=dict(default='present', choices=['present', 'absent'])
)

View file

@ -135,10 +135,7 @@ data:
sample: 192.0.1.0
'''
import os
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
from ansible.module_utils.urls import fetch_url
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule, json
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
@ -155,7 +152,7 @@ def main():
state=dict(type='str', default='present', choices=['query', 'present']),
service=dict(type='str', default=None, choices=['ICMP', 'SNMP', 'web']),
access=dict(type='str', choices=['blocked', 'restricted', 'unrestricted']),
allowed_ips=dict(type='list', element='str'),
allowed_ips=dict(type='list', elements='str'),
)
mutually_exclusive = [('net_name', 'net_id')]
@ -184,7 +181,7 @@ def main():
org_id = meraki.params['org_id']
if not org_id:
org_id = meraki.get_org_id(meraki.params['org_name'])
net_id = None
net_id = meraki.params['net_id']
if net_id is None:
nets = meraki.get_nets(org_id=org_id)
net_id = meraki.get_net_id(org_id, meraki.params['net_name'], data=nets)

View file

@ -68,6 +68,7 @@ options:
description:
- The physical WAN interface on which the traffic will arrive.
choices: [both, internet1, internet2]
type: str
allowed_inbound:
description:
- The ports this mapping will provide access on, and the remote IPs that will be allowed access to the resource.
@ -153,14 +154,15 @@ options:
public_port:
description:
- A port or port ranges that will be forwarded to the host on the LAN.
type: str
type: int
local_port:
description:
- A port or port ranges that will receive the forwarded traffic from the WAN.
type: str
type: int
allowed_ips:
description:
- List of ranges of WAN IP addresses that are allowed to make inbound connections on the specified ports or port ranges (or any).
type: list
protocol:
description:
- Protocol to forward traffic for.
@ -491,9 +493,9 @@ def main():
net_name=dict(type='str', aliases=['name', 'network']),
state=dict(type='str', choices=['present', 'query'], default='present'),
subset=dict(type='list', choices=['1:1', '1:many', 'all', 'port_forwarding'], default='all'),
one_to_one=dict(type='list', element='dict', options=one_to_one_spec),
one_to_many=dict(type='list', element='dict', options=one_to_many_spec),
port_forwarding=dict(type='list', element='dict', options=port_forwarding_spec),
one_to_one=dict(type='list', elements='dict', options=one_to_one_spec),
one_to_many=dict(type='list', elements='dict', options=one_to_many_spec),
port_forwarding=dict(type='list', elements='dict', options=port_forwarding_spec),
)
# the AnsibleModule object will be our abstraction working with Ansible

View file

@ -26,6 +26,7 @@ options:
- Specifies whether SNMP information should be queried or modified.
choices: ['query', 'present']
default: present
type: str
v2c_enabled:
description:
- Specifies whether SNMPv2c is enabled.
@ -38,21 +39,26 @@ options:
description:
- Sets authentication mode for SNMPv3.
choices: ['MD5', 'SHA']
type: str
v3_auth_pass:
description:
- Authentication password for SNMPv3.
- Must be at least 8 characters long.
type: str
v3_priv_mode:
description:
- Specifies privacy mode for SNMPv3.
choices: ['DES', 'AES128']
type: str
v3_priv_pass:
description:
- Privacy password for SNMPv3.
- Must be at least 8 characters long.
type: str
peer_ips:
description:
- Semi-colon delimited IP addresses which can perform SNMP queries.
type: str
net_name:
description:
- Name of network.
@ -228,10 +234,7 @@ data:
returned: success, when network specified
'''
import os
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
from ansible.module_utils.urls import fetch_url
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule, json
from ansible.module_utils.common.dict_transformations import recursive_diff, snake_dict_to_camel_dict
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
@ -317,19 +320,11 @@ def main():
peer_ips=dict(type='str'),
access=dict(type='str', choices=['none', 'community', 'users']),
community_string=dict(type='str', no_log=True),
users=dict(type='list', default=None, element='str', options=user_arg_spec),
users=dict(type='list', default=None, elements='', options=user_arg_spec),
net_name=dict(type='str'),
net_id=dict(type='str'),
)
# seed the result dict in the object
# we primarily care about changed and state
# change is if this module effectively modified the target
# state will include any data that you want your module to pass back
# for consumption, for example, in a subsequent task
result = dict(
changed=False,
)
# the AnsibleModule object will be our abstraction working with Ansible
# this includes instantiation, a couple of common attr would be the
# args/params passed to the execution, as well as if the module

View file

@ -158,7 +158,7 @@ options:
description:
- Default VLAN ID.
- Requires C(ip_assignment_mode) to be C(Bridge mode) or C(Layer 3 roaming).
type: str
type: int
vlan_id:
description:
- ID number of VLAN on SSID.
@ -343,10 +343,7 @@ data:
sample: 0
'''
import os
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
from ansible.module_utils.urls import fetch_url
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule, json
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
@ -415,7 +412,7 @@ def main():
port=dict(type='int'),
secret=dict(type='str', no_log=True),
)
vlan_arg_spec = dict(tags=dict(type='list'),
vlan_arg_spec = dict(tags=dict(type='list', elements='str'),
vlan_id=dict(type='int'),
)
@ -424,7 +421,7 @@ def main():
number=dict(type='int', aliases=['ssid_number']),
name=dict(type='str'),
org_name=dict(type='str', aliases=['organization']),
org_id=dict(type='int'),
org_id=dict(type='str'),
net_name=dict(type='str'),
net_id=dict(type='str'),
enabled=dict(type='bool'),
@ -444,12 +441,12 @@ def main():
'Facebook Wi-Fi',
'Google OAuth',
'Sponsored guest']),
radius_servers=dict(type='list', default=None, element='dict', options=radius_arg_spec),
radius_servers=dict(type='list', default=None, elements='dict', options=radius_arg_spec),
radius_coa_enabled=dict(type='bool'),
radius_failover_policy=dict(type='str', choices=['Deny access', 'Allow access']),
radius_load_balancing_policy=dict(type='str', choices=['Strict priority order', 'Round robin']),
radius_accounting_enabled=dict(type='bool'),
radius_accounting_servers=dict(type='list', element='dict', options=radius_arg_spec),
radius_accounting_servers=dict(type='list', elements='dict', options=radius_arg_spec),
ip_assignment_mode=dict(type='str', choices=['NAT mode',
'Bridge mode',
'Layer 3 roaming',
@ -459,7 +456,7 @@ def main():
concentrator_network_id=dict(type='str'),
vlan_id=dict(type='int'),
default_vlan_id=dict(type='int'),
ap_tags_vlan_ids=dict(type='list', default=None, element='dict', options=vlan_arg_spec),
ap_tags_vlan_ids=dict(type='list', default=None, elements='dict', options=vlan_arg_spec),
walled_garden_enabled=dict(type='bool'),
walled_garden_ranges=dict(type='list'),
min_bitrate=dict(type='float', choices=[1, 2, 5.5, 6, 9, 11, 12, 18, 24, 36, 48, 54]),
@ -559,6 +556,12 @@ def main():
del i['vlan_id']
except KeyError:
pass
try:
tags = ','.join(i['tags'])
del i['tags']
i['tags'] = tags
except KeyError:
pass
ssids = get_ssids(meraki, net_id)
number = meraki.params['number']
if number is None:

View file

@ -46,19 +46,22 @@ options:
type: str
servers:
description:
- List of syslog server settings
- List of syslog server settings.
type: list
suboptions:
host:
description:
- IP address or hostname of Syslog server.
type: str
port:
description:
- Port number Syslog server is listening on.
default: "514"
type: int
roles:
description:
- List of applicable Syslog server roles.
choices: ['Wireless event log',
choices: ['Wireless Event log',
'Appliance event log',
'Switch event log',
'Air Marshal events',
@ -66,6 +69,7 @@ options:
'URLs',
'IDS alerts',
'Security events']
type: list
author:
- Kevin Breit (@kbreit)
@ -136,10 +140,7 @@ data:
sample: "Wireless event log, URLs"
'''
import os
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
from ansible.module_utils.urls import fetch_url
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule, json
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
@ -164,7 +165,7 @@ def main():
argument_spec = meraki_argument_spec()
argument_spec.update(net_id=dict(type='str'),
servers=dict(type='list', element='dict', options=server_arg_spec),
servers=dict(type='list', elements='dict', options=server_arg_spec),
state=dict(type='str', choices=['present', 'query'], default='present'),
net_name=dict(type='str', aliases=['name', 'network']),
)

View file

@ -1105,7 +1105,6 @@ lib/ansible/modules/cloud/openstack/os_volume.py validate-modules:doc-missing-ty
lib/ansible/modules/cloud/openstack/os_volume.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/cloud/openstack/os_volume.py validate-modules:undocumented-parameter
lib/ansible/modules/cloud/openstack/os_volume_snapshot.py validate-modules:doc-missing-type
lib/ansible/modules/cloud/openstack/os_zone.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/cloud/openstack/os_zone.py validate-modules:doc-missing-type
lib/ansible/modules/cloud/openstack/os_zone.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/cloud/oracle/oci_vcn.py validate-modules:parameter-type-not-in-doc
@ -3942,17 +3941,11 @@ lib/ansible/modules/network/meraki/meraki_mx_l3_firewall.py validate-modules:par
lib/ansible/modules/network/meraki/meraki_mx_l7_firewall.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/network/meraki/meraki_mx_l7_firewall.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_mx_l7_firewall.py pylint:ansible-bad-function
lib/ansible/modules/network/meraki/meraki_nat.py validate-modules:doc-type-does-not-match-spec
lib/ansible/modules/network/meraki/meraki_nat.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_network.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_organization.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_snmp.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_ssid.py validate-modules:doc-required-mismatch
lib/ansible/modules/network/meraki/meraki_ssid.py validate-modules:doc-type-does-not-match-spec
lib/ansible/modules/network/meraki/meraki_switchport.py validate-modules:doc-required-mismatch
lib/ansible/modules/network/meraki/meraki_switchport.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_syslog.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/network/meraki/meraki_syslog.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_vlan.py validate-modules:missing-suboption-docs
lib/ansible/modules/network/meraki/meraki_vlan.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/network/meraki/meraki_vlan.py validate-modules:undocumented-parameter