Hello! I’m developping a custom Ansible module and I’m struggling to set up mu argument specs. I’d like to add some conditionals to it ( like ‘required_one_of’, ‘required_if’ ), but it looks like you’re only able to do it at the top level of the params dict.
But this doesn’t seem to work, because it looks for config.vlan and config.pvid keys at the top level of the params dict, and it doesn’t go inside of the config dict.
That’s not what the documentation says. If you read through Ansible module architecture — Ansible Community Documentation you’ll see that those appear both in the list of behavioral attributes for arguments and as optional arguments for AnsibleModule().
I think there might be a misunderstanding. I understand that options as “required_one_of”, “mutually_exclusive” etc are optional argument for AnsibleModule().
So, for example, with this specific argument_spec dict :
My question is, how can I achieve the same behaviour but with nested elements? For example, if I want to mutually exclude vlan and pvid inside of the config list, what would be the option argument “mutually_exclusive” for AnsibleModule()
However, based on where you have your “type: list” and the use of the plural “interfaces” for what is a single string, my guess is you still have some issue to work through.