Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
In JSON Schema one can use the additionalProperties key to validate properties whose names are not know. You can still impose restrictions on their type. How to do this in an Ansible role argument...
Question
ansible
#3: Post edited
How to validate Ansible role dictionary arguments "additionalProperties"
- How to validate Ansible role dictionary argument's "additionalProperties"
#2: Post edited
- In JSON Schema one can use the [additionalProperties](https://json-schema.org/understanding-json-schema/reference/object#additional-properties) key to validate properties whose names are not know. You can still impose restrictions on their type.
- **How to do this in an [Ansible role argument spec](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-argument-validation)?**
- This doesn't work:
- ```yaml
- argument_specs:
- main:
short_description: The main entry point for the myapp role.- options:
- dictionary_argument:
- description: A map from string to integers.
- type: dict
- required: true
- options:
- type: int
- ```
- In JSON Schema one can use the [additionalProperties](https://json-schema.org/understanding-json-schema/reference/object#additional-properties) key to validate properties whose names are not know. You can still impose restrictions on their type.
- **How to do this in an [Ansible role argument spec](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-argument-validation)?**
- This doesn't work:
- ```yaml
- argument_specs:
- main:
- options:
- dictionary_argument:
- description: A map from string to integers.
- type: dict
- required: true
- options:
- type: int
- ```
#1: Initial revision
How to validate Ansible role dictionary arguments "additionalProperties"
In JSON Schema one can use the [additionalProperties](https://json-schema.org/understanding-json-schema/reference/object#additional-properties) key to validate properties whose names are not know. You can still impose restrictions on their type. **How to do this in an [Ansible role argument spec](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-argument-validation)?** This doesn't work: ```yaml argument_specs: main: short_description: The main entry point for the myapp role. options: dictionary_argument: description: A map from string to integers. type: dict required: true options: type: int ```