diff --git a/changelogs/fragments/54419-nios-member-updates.yaml b/changelogs/fragments/54419-nios-member-updates.yaml new file mode 100644 index 00000000000..71b5f66169d --- /dev/null +++ b/changelogs/fragments/54419-nios-member-updates.yaml @@ -0,0 +1,2 @@ +bugfixes: +- To fix the nios member module params - https://github.com/ansible/ansible/pull/54419 diff --git a/lib/ansible/module_utils/net_tools/nios/api.py b/lib/ansible/module_utils/net_tools/nios/api.py index bf4a061b1c3..6e5ab98805b 100644 --- a/lib/ansible/module_utils/net_tools/nios/api.py +++ b/lib/ansible/module_utils/net_tools/nios/api.py @@ -151,8 +151,16 @@ def member_normalize(member_spec): It will remove any arguments that are set to None since WAPI will error on that condition. The remainder of the value validation is performed by WAPI + Some parameters in ib_spec are passed as a list in order to pass the validation for elements. + In this function, they are converted to dictionary. ''' + member_elements = ['vip_setting', 'ipv6_setting', 'lan2_port_setting', 'mgmt_port_setting', + 'pre_provisioning', 'network_setting', 'v6_network_setting', + 'ha_port_setting', 'lan_port_setting', 'lan2_physical_setting', + 'lan_ha_port_setting', 'mgmt_network_setting', 'v6_mgmt_network_setting'] for key in member_spec.keys(): + if key in member_elements: + member_spec[key] = member_spec[key][0] if isinstance(member_spec[key], dict): member_spec[key] = member_normalize(member_spec[key]) elif isinstance(member_spec[key], list): diff --git a/lib/ansible/modules/net_tools/nios/nios_member.py b/lib/ansible/modules/net_tools/nios/nios_member.py index 07365c04a06..0776e8698e1 100644 --- a/lib/ansible/modules/net_tools/nios/nios_member.py +++ b/lib/ansible/modules/net_tools/nios/nios_member.py @@ -305,9 +305,9 @@ EXAMPLES = ''' nios_member: host_name: member01.localdomain vip_setting: - address: 192.168.1.100 - subnet_mask: 255.255.255.0 - gateway: 192.168.1.1 + - address: 192.168.1.100 + subnet_mask: 255.255.255.0 + gateway: 192.168.1.1 config_addr_type: IPV4 platform: VNIOS comment: "Created by Ansible" @@ -321,9 +321,9 @@ EXAMPLES = ''' nios_member: host_name: memberha.localdomain vip_setting: - address: 192.168.1.100 - subnet_mask: 255.255.255.0 - gateway: 192.168.1.1 + - address: 192.168.1.100 + subnet_mask: 255.255.255.0 + gateway: 192.168.1.1 config_addr_type: IPV4 platform: VNIOS enable_ha: true @@ -346,14 +346,14 @@ EXAMPLES = ''' nios_member: name: member01.localdomain pre_provisioning: - hardware_info: - - hwmodel: IB-VM-820 - hwtype: IB-VNIOS - licenses: - - dns - - dhcp - - enterprise - - vnios + - hardware_info: + - hwmodel: IB-VM-820 + hwtype: IB-VNIOS + licenses: + - dns + - dhcp + - enterprise + - vnios comment: "Updated by Ansible" state: present provider: @@ -403,23 +403,23 @@ def main(): lan2_port_spec = dict( enabled=dict(type='bool'), - network_setting=dict(type='dict', elements='dict', options=ipv4_spec), - v6_network_setting=dict(type='dict', elements='dict', options=ipv6_spec), + network_setting=dict(type='list', elements='dict', options=ipv4_spec), + v6_network_setting=dict(type='list', elements='dict', options=ipv6_spec), ) ha_port_spec = dict( ha_ip_address=dict(), - ha_port_setting=dict(type='dict', elements='dict', options=port_spec), - lan_port_setting=dict(type='dict', elements='dict', options=port_spec), + ha_port_setting=dict(type='list', elements='dict', options=port_spec), + lan_port_setting=dict(type='list', elements='dict', options=port_spec), mgmt_lan=dict(), mgmt_ipv6addr=dict(), ) node_spec = dict( - lan2_physical_setting=dict(type='dict', elements='dict', options=port_spec), - lan_ha_port_setting=dict(type='dict', elements='dict', options=ha_port_spec), - mgmt_network_setting=dict(type='dict', elements='dict', options=ipv4_spec), - v6_mgmt_network_setting=dict(type='dict', elements='dict', options=ipv6_spec), + lan2_physical_setting=dict(type='list', elements='dict', options=port_spec), + lan_ha_port_setting=dict(type='list', elements='dict', options=ha_port_spec), + mgmt_network_setting=dict(type='list', elements='dict', options=ipv4_spec), + v6_mgmt_network_setting=dict(type='list', elements='dict', options=ipv6_spec), ) mgmt_port_spec = dict( @@ -452,22 +452,22 @@ def main(): ib_spec = dict( host_name=dict(required=True, aliases=['name'], ib_req=True), - vip_setting=dict(type='dict', elements='dict', options=ipv4_spec), - ipv6_setting=dict(type='dict', elements='dict', options=ipv6_spec), + vip_setting=dict(type='list', elements='dict', options=ipv4_spec), + ipv6_setting=dict(type='list', elements='dict', options=ipv6_spec), config_addr_type=dict(default='IPV4'), comment=dict(), enable_ha=dict(type='bool', default=False), router_id=dict(type='int'), lan2_enabled=dict(type='bool', default=False), - lan2_port_setting=dict(type='dict', elements='dict', options=lan2_port_spec), + lan2_port_setting=dict(type='list', elements='dict', options=lan2_port_spec), platform=dict(default='INFOBLOX'), node_info=dict(type='list', elements='dict', options=node_spec), - mgmt_port_setting=dict(type='dict', elements='dict', options=mgmt_port_spec), + mgmt_port_setting=dict(type='list', elements='dict', options=mgmt_port_spec), upgrade_group=dict(default='Default'), use_syslog_proxy_setting=dict(type='bool'), external_syslog_server_enable=dict(type='bool'), syslog_servers=dict(type='list', elements='dict', options=syslog_spec), - pre_provisioning=dict(type='dict', elements='dict', options=pre_prov_spec), + pre_provisioning=dict(type='list', elements='dict', options=pre_prov_spec), extattrs=dict(type='dict'), create_token=dict(type='bool', default=False), )