So I was eager to try out the new role argument validation which is in the 
pipeline for 2.11 
(https://docs.ansible.com/ansible/devel/user_guide/playbooks_reuse_roles.html#role-argument-validation),
 
but immediately ran into an issue, and thought it would be good to discuss.

The issue is the ability to handle arbitrary keys within dictionaries. For 
example if you have a variable such as:
users:
  john:
    id: 1000
    shell: /bin/bash
  marcy:
    id: 1001
    shell: /bin/zsh

There is currently no way to document this as the keys are arbitrary (user 
names), and the spec requires all keys to be explicitly declared.
Now I did originally open this as an issue on GitHub 
(https://github.com/ansible/ansible/issues/74001), however it was closed 
without much discussion other than "not supported, too difficult, not 
planned". But I'm not quite following that. I may not have a complete 
understanding of the code, but it looks like it boils down to the 
_get_unsupported_parameters() function, which looks like it'd be rather 
easy to support a pre-defined/constant spec key (e.g. "*") to act as a 
catch-all for unknown keys. Now this wouldn't be able to declare the key 
type (e.g. string/int/bool/...), but for that, maybe some per-type 
constants would address that (e.g. "*string"/"*int").

So can someone explain why this, or something like it can't be done? Or why 
it's too difficult?

Thanks

-Patrick

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/10115f56-7fc7-4b3b-9462-b3c53f1281b9n%40googlegroups.com.

Reply via email to