Note
This plugin is part of the ansible.utils collection (version 2.0.0).
To install it use: ansible-galaxy collection install ansible.utils
.
To use it in a playbook, specify: ansible.utils.validate
.
New in version 1.0.0: of ansible.utils
Note
This module has a corresponding action plugin.
Parameter | Choices/Defaults | Comments |
---|---|---|
criteria raw / required | The criteria used for validation of data. For the type of criteria refer to the documentation of individual validate plugins. | |
data raw / required | Data that will be validated against criteria. For the type of data refer to the documentation of individual validate plugins. | |
engine string | Default: "ansible.utils.jsonschema" | The name of the validate plugin to use. The engine value should follow the fully qualified collection name format, that is <org-name>.<collection-name>.<validate-plugin-name>. |
Note
- name: set facts for data and criteria ansible.builtin.set_fact: data: "{{ lookup('ansible.builtin.file', './validate/data/show_interfaces_iosxr.json')}}" criteria: "{{ lookup('ansible.builtin.file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}" - name: validate data in with jsonschema engine (by passing task vars as configurable plugin options) ansible.utils.validate: data: "{{ data }}" criteria: "{{ criteria }}" engine: ansible.utils.jsonschema vars: ansible_jsonschema_draft: draft7
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
errors list / elements=string | when data value is invalid | The list of errors in data based on the criteria. |
msg string | always | The msg indicates if the data is valid as per the criteria. In case data is valid return success message all checks passed. In case data is invalid return error message Validation errors were found along with more information on error is available. |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/utils/validate_module.html