Repository: ansible-collections/community.general

Issue:
[nios_zone] Warnings when using zone_format parameter


##### SUMMARY
Using `zone_format: "FORWARD"` in the "nios_zone" module will cause a strange warning:
`[WARNING]: Both option zone_format and its alias zone_format are set.`

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
nios_zone

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
 ansible 2.9.10
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr  2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
CentOS Linux release 7.8

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: "create Forward Zone"
  connection: local
  nios_zone:
    provider: "{{ grid_connector }}"
    restart_if_needed: true
    name:                   "{{ zone.fqdn }}"
    ns_group:               "{{ zone.ns_group}}"
    view:                   "{{ zone.view|default('default') }}"
    state:                  "{{ zone.state|default('present') }}"
    zone_format:            "{{ zone.zone_format|default('FORWARD') }}"
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->


##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
playbook works as expected but gives a strange warning:
<!--- Paste verbatim command output between quotes -->
```paste below
[WARNING]: Both option zone_format and its alias zone_format are set.
```



Discussion:
Files identified in the description:
* [`plugins/modules/net_tools/nios/nios_zone.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/modules/net_tools/nios/nios_zone.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @NilashishC @Qalthos @danielmellado @ganeshrn @justjais @nerzhul @privateip @sganesh-infoblox @trishnaguha
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I get warnings like this when I use `nios_fixed_address` as well (on 2.9.15).

Task:
```
- name: make a host record
  nios_fixed_address:
    name: my-record-4.example.com
    ipaddr: 192.168.100.4
    network: 192.168.100.0/24
    mac: 00:00:00:00:00:00
    provider:
      host: nios.example.com
      username: admin
      password: infoblox
      validate_certs: no
```

Output:
```
TASK [make a host record] **************************************************************************************************************
[WARNING]: Both option ipaddr and its alias ipaddr are set.
[WARNING]: Both option mac and its alias mac are set.
[WARNING]: Both option network and its alias network are set.
ok: [localhost]
```

Same behavior, works as expected, but throwing warnings about aliases. Seems to me that aliases are set in the module code when they shouldn't be.

Resolving patch:
diff --git a/plugins/modules/net_tools/nios/nios_fixed_address.py b/plugins/modules/net_tools/nios/nios_fixed_address.py
--- a/plugins/modules/net_tools/nios/nios_fixed_address.py
+++ b/plugins/modules/net_tools/nios/nios_fixed_address.py
@@ -37,8 +37,6 @@
   network:
     description:
       - Specifies the network range in which ipaddr exists.
-    aliases:
-      - network
   network_view:
     description:
       - Configures the name of the network view to associate with this
@@ -244,10 +242,10 @@ def main():
 
     ib_spec = dict(
         name=dict(required=True),
-        ipaddr=dict(required=True, aliases=['ipaddr'], ib_req=True),
-        mac=dict(required=True, aliases=['mac'], ib_req=True),
-        network=dict(required=True, aliases=['network']),
-        network_view=dict(default='default', aliases=['network_view']),
+        ipaddr=dict(required=True, ib_req=True),
+        mac=dict(required=True, ib_req=True),
+        network=dict(required=True),
+        network_view=dict(default='default'),
 
         options=dict(type='list', elements='dict', options=option_spec, transform=options),
 
diff --git a/plugins/modules/net_tools/nios/nios_host_record.py b/plugins/modules/net_tools/nios/nios_host_record.py
--- a/plugins/modules/net_tools/nios/nios_host_record.py
+++ b/plugins/modules/net_tools/nios/nios_host_record.py
@@ -73,8 +73,6 @@
           - Configures the hardware MAC address for the host record. If user makes
             DHCP to true, user need to mention MAC address.
         required: false
-        aliases:
-          - mac
       add:
         description:
           - If user wants to add the ipv4 address to an existing host record.
@@ -82,8 +80,6 @@
             as new IP address is allocated to existing host record. See examples.
         type: bool
         required: false
-        aliases:
-          - add
         version_added: '0.2.0'
       remove:
         description:
@@ -92,8 +88,6 @@
             as IP address is de-allocated from an existing host record. See examples.
         type: bool
         required: false
-        aliases:
-          - remove
         version_added: '0.2.0'
   ipv6addrs:
     description:
@@ -294,15 +288,15 @@ def main():
     ipv4addr_spec = dict(
         ipv4addr=dict(required=True, aliases=['address'], ib_req=True),
         configure_for_dhcp=dict(type='bool', required=False, aliases=['dhcp'], ib_req=True),
-        mac=dict(required=False, aliases=['mac'], ib_req=True),
-        add=dict(type='bool', aliases=['add'], required=False),
-        remove=dict(type='bool', aliases=['remove'], required=False)
+        mac=dict(required=False, ib_req=True),
+        add=dict(type='bool', required=False),
+        remove=dict(type='bool', required=False)
     )
 
     ipv6addr_spec = dict(
         ipv6addr=dict(required=True, aliases=['address'], ib_req=True),
-        configure_for_dhcp=dict(type='bool', required=False, aliases=['configure_for_dhcp'], ib_req=True),
-        mac=dict(required=False, aliases=['mac'], ib_req=True)
+        configure_for_dhcp=dict(type='bool', required=False, ib_req=True),
+        mac=dict(required=False, ib_req=True)
     )
 
     ib_spec = dict(
diff --git a/plugins/modules/net_tools/nios/nios_zone.py b/plugins/modules/net_tools/nios/nios_zone.py
--- a/plugins/modules/net_tools/nios/nios_zone.py
+++ b/plugins/modules/net_tools/nios/nios_zone.py
@@ -184,7 +184,7 @@ def main():
 
     ib_spec = dict(
         fqdn=dict(required=True, aliases=['name'], ib_req=True, update=False),
-        zone_format=dict(default='FORWARD', aliases=['zone_format'], ib_req=False),
+        zone_format=dict(default='FORWARD', ib_req=False),
         view=dict(default='default', aliases=['dns_view'], ib_req=True),
 
         grid_primary=dict(type='list', elements='dict', options=grid_spec),


Test patch:
diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt
--- a/tests/sanity/ignore-2.10.txt
+++ b/tests/sanity/ignore-2.10.txt
@@ -759,7 +759,6 @@ plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-elemen
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-missing-type
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:invalid-ansiblemodule-schema
-plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:undocumented-parameter
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-default-does-not-match-spec
@@ -768,7 +767,6 @@ plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-missing-
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:invalid-ansiblemodule-schema
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:nonexistent-parameter-documented
-plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-list-no-elements
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:undocumented-parameter
@@ -837,7 +835,6 @@ plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-elements-mismat
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-missing-type
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:invalid-ansiblemodule-schema
-plugins/modules/net_tools/nios/nios_zone.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:undocumented-parameter
 plugins/modules/net_tools/nsupdate.py validate-modules:parameter-list-no-elements
diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt
--- a/tests/sanity/ignore-2.11.txt
+++ b/tests/sanity/ignore-2.11.txt
@@ -759,7 +759,6 @@ plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-elemen
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-missing-type
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:invalid-ansiblemodule-schema
-plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:undocumented-parameter
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-default-does-not-match-spec
@@ -768,7 +767,6 @@ plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-missing-
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:invalid-ansiblemodule-schema
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:nonexistent-parameter-documented
-plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-list-no-elements
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_host_record.py validate-modules:undocumented-parameter
@@ -837,7 +835,6 @@ plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-elements-mismat
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-missing-type
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:doc-required-mismatch
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:invalid-ansiblemodule-schema
-plugins/modules/net_tools/nios/nios_zone.py validate-modules:parameter-alias-self
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:parameter-type-not-in-doc
 plugins/modules/net_tools/nios/nios_zone.py validate-modules:undocumented-parameter
 plugins/modules/net_tools/nsupdate.py validate-modules:parameter-list-no-elements