Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.145.10.9
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/ansible/utils/plugins/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/ansible/utils/plugins/modules/validate.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2020 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function


__metaclass__ = type


DOCUMENTATION = """
module: validate
author:
- Bradley Thornton (@cidrblock)
- Ganesh Nalawade (@ganeshrn)
short_description: Validate data with provided criteria
description:
- Validate data with provided criteria based on the validation engine.
version_added: 1.0.0
options:
    data:
        type: raw
        description:
        - Data that will be validated against I(criteria). For the type of data refer to the
          documentation of individual validate plugins.
        required: True
    engine:
        type: str
        description:
        - 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>.
        default: ansible.utils.jsonschema
    criteria:
        type: raw
        description:
        - The criteria used for validation of I(data). For the type of criteria refer to the
          documentation of individual validate plugins.
        required: True
notes:
- For the type of options I(data) and I(criteria) refer to the individual validate plugin
  documentation that is represented in the value of I(engine) option.
- For additional plugin configuration options refer to the individual validate plugin
  documentation that is represented by the value of I(engine) option.
- The plugin configuration option can be either passed as task or environment variables.
- The precedence of the validate plugin configurable option is task variables followed
  by the environment variables.
"""

EXAMPLES = r"""
- 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

- name: validate configuration with config plugin (see config plugin for criteria examples)
  ansible.utils.validate:
    data: "{{ lookup('ansible.builtin.file', './backup/eos.config' }}"
    criteria: "{{ lookup('ansible.builtin.file', './validate/criteria/config/eos_config_rules.yaml' }}"
    engine: ansible.utils.config
"""

RETURN = r"""
msg:
  description:
  - The msg indicates if the I(data) is valid as per the I(criteria).
  - In case data is valid return success message B(all checks passed).
  - In case data is invalid return error message B(Validation errors were found)
    along with more information on error is available.
  returned: always
  type: str
errors:
  description: The list of errors in I(data) based on the I(criteria).
  returned: when I(data) value is invalid
  type: list
  elements: str
"""

Anon7 - 2022
AnonSec Team