# deep nested argument-spec is not getting validated

**URL:** <https://forum.ansible.com/t/deep-nested-argument-spec-is-not-getting-validated/28984>\
**Category:** Ansible Developer\
**Created:** [November 9, 2018, 6:05am UTC](https://forum.ansible.com/t/deep-nested-argument-spec-is-not-getting-validated/28984 "2018-11-09T06:05:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suhas\_Bharadwaj](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@Suhas\_Bharadwaj](https://forum.ansible.com/u/Suhas_Bharadwaj)\
**Post date:** [November 9, 2018, 6:05am UTC](https://forum.ansible.com/t/deep-nested-argument-spec-is-not-getting-validated/28984/1 "2018-11-09T06:05:26Z")

</div>

I’am writing a new module and the argument spec is like this

member\_spec = dict(  
pwwn=dict(required=True, type=‘str’, aliases=[‘interface’, ‘device-alias’]),  
devtype=dict(type=‘str’, choices=[‘initiator’, ‘target’, ‘both’])  
)

zoneadd\_spec = dict(  
zonename=dict(type=‘str’, required=True),  
members=dict(type=‘list’, element=‘dict’, options=member\_spec)  
)

zonedetails\_spec = dict(  
vsanid=dict(required=True, type=‘int’),  
mode=dict(type=‘str’, choices=[‘enhanced’, ‘basic’]),  
default\_zone=dict(type=‘str’, choices=[‘permit’, ‘deny’]),  
smart\_zoning=dict(type=‘bool’),  
zone\_remove=dict(type=‘list’, elements=‘str’),  
zone\_add=dict(type=‘list’, elements=‘dict’, options=zoneadd\_spec)  
)

argument\_spec = dict(  
zone\_details=dict(type=‘list’, elements=‘dict’, options=zonedetails\_spec)  
)

My play is like this:

- name: Test that zone module works  
nxos\_zone:  
provider: “{{ creds }}”  
zone\_details:
- vsanid: 1  
mode: enhanced  
smart\_zoning: yes  
default\_zone: permit  
zone\_add:
- zonename: zone1  
members:
- {device-alias: ‘abc’, devtype: ‘bo’}
- {pwn: ‘11:11:11:11:11:11:11:11’, dvtype: ‘initiator’}
- {interface: ‘fc1/2’, devtype: ‘target’}
- zonename: zone2  
members:
- {device-alias: ‘abc’}
- {pwwn: ‘11:11:11:11:11:11:11:11’}
- vsanid: 2  
mode: basic  
smart\_zoning: no  
default\_zone: deny  
zone\_remove:
- zone32
- zone56

When i run this play there was no error seen, i was expecting an error because  
Notice that the devtype is ‘bo’ instead of ‘both’ and key is ‘pwn’ instead of ‘pwwn’ and instead of ‘devtype’ i have ‘dvtype’

So looks like basically ‘member\_spec’ is not getting validated, any reason?

---

<div class="post-metadata">

**Author:** ![ganeshrn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ganeshrn/32/1021_2.png) [@ganeshrn](https://forum.ansible.com/u/ganeshrn)\
**Post date:** [November 9, 2018, 10:09am UTC](https://forum.ansible.com/t/deep-nested-argument-spec-is-not-getting-validated/28984/2 "2018-11-09T10:09:47Z")

</div>

The “members” option "zoneadd\_spec " spec should have “elements” instead of “element”\> members=dict(type=‘list’, element **s** =‘dict’, options=member\_spec)

Regards,  
Ganesh

---

<div class="post-metadata">

**Author:** ![Suhas\_Bharadwaj](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@Suhas\_Bharadwaj](https://forum.ansible.com/u/Suhas_Bharadwaj)\
**Post date:** [November 12, 2018, 9:14am UTC](https://forum.ansible.com/t/deep-nested-argument-spec-is-not-getting-validated/28984/3 "2018-11-12T09:14:20Z")

</div>

Duh!!!  
Thank you!!
