Ansible 3.0.0 collection inclusion releated changes (#32)
Ansible 3.0.0 collection inclusion releated changes Reviewed-by: https://github.com/apps/ansible-zuulpull/34/head
parent
038e2502fa
commit
dccab0d9f1
|
@ -105,8 +105,14 @@ Please read and familiarize yourself with this document.
|
|||
## Release notes
|
||||
<!--Add a link to a changelog.md file or an external docsite to cover this information. -->
|
||||
Release notes are available [here](https://github.com/ansible-collections/ansible.utils/blob/main/changelogs/CHANGELOG.rst)
|
||||
For automated release announcements refer [here](https://twitter.com/AnsibleContent).
|
||||
|
||||
|
||||
## Roadmap
|
||||
For information on releasing, versioning and deprecation see the [stratergy document](https://access.redhat.com/articles/4993781).
|
||||
|
||||
In general, major versions can contain breaking changes, while minor versions only contain new features (like new plugin addition) and bugfixes.
|
||||
The releases will be done on an as-needed basis when new features and/or bugfixes are done.
|
||||
|
||||
<!-- Optional. Include the roadmap for this collection, and the proposed release/versioning strategy so users can anticipate the upgrade/update cycle. -->
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
trivial:
|
||||
- Ansible 3.0.0 collection inclusion related changes (https://github.com/ansible-collections/ansible-inclusion/discussions/4)
|
|
@ -195,11 +195,11 @@ Notes
|
|||
- The default Ansible search path for the templates directory is used for parser templates as well
|
||||
- Some parsers may have additional configuration options available. See the parsers/vars key and the parser's documentation
|
||||
- Some parsers require third-party python libraries be installed on the Ansible control node and a specific python version
|
||||
- e.g. Pyats requires pyats and genie and requires Python 3
|
||||
- e.g. ntc_templates requires ntc_templates
|
||||
- e.g. textfsm requires textfsm
|
||||
- e.g. ttp requires ttp
|
||||
- e.g. xml requires xml_to_dict
|
||||
- example Pyats requires pyats and genie and requires Python 3
|
||||
- example ntc_templates requires ntc_templates
|
||||
- example textfsm requires textfsm
|
||||
- example ttp requires ttp
|
||||
- example xml requires xml_to_dict
|
||||
- Support of 3rd party python libraries is limited to the use of their public APIs as documented
|
||||
- Additional information and examples can be found in the parsing user guide:
|
||||
- https://docs.ansible.com/ansible/latest/network/user_guide/cli_parsing.html
|
||||
|
@ -260,7 +260,7 @@ Examples
|
|||
# -------------
|
||||
# The ntc_templates use 'vendor_platform' for the file name
|
||||
# it will be derived from ansible_network_os if not provided
|
||||
# e.g. cisco.ios.ios => cisco_ios
|
||||
# example cisco.ios.ios => cisco_ios
|
||||
|
||||
- name: Run command and parse with ntc_templates
|
||||
ansible.utils.cli_parse:
|
||||
|
|
|
@ -148,7 +148,7 @@ Examples
|
|||
|
||||
.. code-block:: yaml
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
before:
|
||||
a:
|
||||
b:
|
||||
|
|
|
@ -133,7 +133,7 @@ Parameters
|
|||
<td>
|
||||
<div>The value used to test each list item against.</div>
|
||||
<div>{'Not required for simple tests (eg': '<code>true</code>, <code>false</code>, <code>even</code>, <code>odd</code>)'}</div>
|
||||
<div>May be a <code>string</code>, <code>boolean</code>, <code>number</code>, <code>regular expesion</code> <code>dict</code> etc, depending on the <code>test</code> used</div>
|
||||
<div>May be a <code>string</code>, <code>boolean</code>, <code>number</code>, <code>regular expression</code> <code>dict</code> and so on, depending on the <code>test</code> used</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -171,14 +171,15 @@ Examples
|
|||
|
||||
#### Simple examples
|
||||
|
||||
- set_fact:
|
||||
- name: Define a list
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -188,7 +189,7 @@ Examples
|
|||
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -199,7 +200,7 @@ Examples
|
|||
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of(test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -228,7 +229,8 @@ Examples
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- name: Define a list with hostname and type
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -240,7 +242,7 @@ Examples
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ data|ansible.utils.index_of('eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -296,7 +298,7 @@ Examples
|
|||
# name: mgmt0
|
||||
|
||||
- name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
found: "{{ found + entry }}"
|
||||
with_indexed_items: "{{ current_l3.gathered }}"
|
||||
vars:
|
||||
|
@ -330,7 +332,8 @@ Examples
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- name: Define interface configuration facts
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -125,7 +125,7 @@ Parameters
|
|||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<div>The value used to test each list item against. Not required for simple tests (eg: <code>true</code>, <code>false</code>, <code>even</code>, <code>odd</code>) May be a <code>string</code>, <code>boolean</code>, <code>number</code>, <code>regular expesion</code> <code>dict</code> etc, depending on the <code>test</code> used.</div>
|
||||
<div>The value used to test each list item against. Not required for simple tests (eg: <code>true</code>, <code>false</code>, <code>even</code>, <code>odd</code>) May be a <code>string</code>, <code>boolean</code>, <code>number</code>, <code>regular expression</code> <code>dict</code> and so on, depending on the <code>test</code> used.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -146,7 +146,7 @@ Parameters
|
|||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<div>When only a single entry in the <code>data</code> is matched, the index of that entry is returned as an integer. If set to <code>True</code>, the return value will always be a list, even if only a single entry is matched. This can also be accomplised using <code>query</code> or <code>q</code> instead of <code>lookup</code>. <a href='https://docs.ansible.com/ansible/latest/plugins/lookup.html'>https://docs.ansible.com/ansible/latest/plugins/lookup.html</a></div>
|
||||
<div>When only a single entry in the <code>data</code> is matched, the index of that entry is returned as an integer. If set to <code>True</code>, the return value will always be a list, even if only a single entry is matched. This can also be accomplished using <code>query</code> or <code>q</code> instead of <code>lookup</code>. <a href='https://docs.ansible.com/ansible/latest/plugins/lookup.html'>https://docs.ansible.com/ansible/latest/plugins/lookup.html</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -162,14 +162,14 @@ Examples
|
|||
|
||||
#### Simple examples
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -178,7 +178,7 @@ Examples
|
|||
# indices: '1'
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -188,7 +188,7 @@ Examples
|
|||
# - 1
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data=data, test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -232,7 +232,7 @@ Examples
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -244,7 +244,7 @@ Examples
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ lookup('ansible.utils.index_of', data, 'eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -300,7 +300,7 @@ Examples
|
|||
# name: mgmt0
|
||||
|
||||
- name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
found: "{{ found + entry }}"
|
||||
with_indexed_items: "{{ current_l3.gathered }}"
|
||||
vars:
|
||||
|
@ -334,7 +334,7 @@ Examples
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -19,7 +19,7 @@ Synopsis
|
|||
--------
|
||||
- Flatten a complex object into a dictionary of paths and values.
|
||||
- Paths are dot delimited whenever possible.
|
||||
- Brakets are used for list indices and keys that contain special characters.
|
||||
- Brackets are used for list indices and keys that contain special characters.
|
||||
- ``to_paths`` is also available as a ``lookup plugin`` for convenience.
|
||||
- Using the parameters below- ``var|ansible.utils.to_paths(prepend, wantlist``)
|
||||
|
||||
|
@ -160,7 +160,7 @@ Examples
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Flatten the complex object
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ result.json|ansible.utils.to_paths }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -147,7 +147,7 @@ Examples
|
|||
#### Using a complex object
|
||||
|
||||
- name: Make an API call
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "https://nxos101/restconf/data/openconfig-interfaces:interfaces"
|
||||
headers:
|
||||
accept: "application/yang.data+json"
|
||||
|
@ -158,7 +158,7 @@ Examples
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Flatten the complex object
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ lookup('ansible.utils.to_paths', result.json) }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -103,7 +103,7 @@ Examples
|
|||
|
||||
# Update an exisitng fact, dot or bracket notation
|
||||
- name: Set a fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -134,7 +134,7 @@ Examples
|
|||
# Lists can be appended, new keys added to dictionaries
|
||||
|
||||
- name: Set a fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
b1:
|
||||
|
@ -176,7 +176,7 @@ Examples
|
|||
#####################################################################
|
||||
|
||||
- name: Set fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
addresses:
|
||||
- raw: 10.1.1.0/255.255.255.0
|
||||
name: servers
|
||||
|
@ -186,7 +186,7 @@ Examples
|
|||
name: dns
|
||||
|
||||
- name: Build a list of updates
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
update_list: "{{ update_list + update }}"
|
||||
loop: "{{ addresses }}"
|
||||
loop_control:
|
||||
|
@ -343,7 +343,7 @@ Examples
|
|||
- l3_interfaces
|
||||
|
||||
- name: Build the list of updates to make
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
updates: "{{ updates + [entry] }}"
|
||||
vars:
|
||||
updates: []
|
||||
|
|
|
@ -90,7 +90,7 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>The name of the validator plugin to use.</div>
|
||||
<div>This option can be passed in lookup plugin as a key, value pair. For example <em>config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema'</em>), in this case the value <em>ansible.utils.jsonschema</em> represents the engine to be use for data valdiation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>This option can be passed in lookup plugin as a key, value pair. For example <em>config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema'</em>), in this case the value <em>ansible.utils.jsonschema</em> represents the engine to be use for data validation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>The value should be in fully qualified collection name format that is <em><org-name>.<collection-name>.<validator-plugin-name></em>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -115,9 +115,9 @@ Examples
|
|||
.. code-block:: yaml
|
||||
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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 json format using jsonschema by passing plugin configuration variable as key/value pairs
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -90,7 +90,7 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>The name of the validate plugin to use.</div>
|
||||
<div>This option can be passed in lookup plugin as a key, value pair. For example <em>lookup(config_data, config_criteria, engine='ansible.utils.jsonschema'</em>), in this case the value <em>ansible.utils.jsonschema</em> represents the engine to be use for data valdiation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>This option can be passed in lookup plugin as a key, value pair. For example <em>lookup(config_data, config_criteria, engine='ansible.utils.jsonschema'</em>), in this case the value <em>ansible.utils.jsonschema</em> represents the engine to be use for data validation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>The value should be in fully qualified collection name format that is <em><org-name>.<collection-name>.<validate-plugin-name></em>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -115,9 +115,9 @@ Examples
|
|||
.. code-block:: yaml
|
||||
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
ansible.builtinset_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 json format using jsonschema with lookup plugin by passing plugin configuration variable as key/value pairs
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -102,9 +102,9 @@ Examples
|
|||
.. code-block:: yaml
|
||||
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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:
|
||||
|
|
|
@ -90,7 +90,7 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>The name of the validate plugin to use.</div>
|
||||
<div>This option can be passed in test plugin as a key, value pair For example <em>config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria</em>), in this case the value of <em>engine</em> key represents the engine to be use for data valdiation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>This option can be passed in test plugin as a key, value pair For example <em>config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria</em>), in this case the value of <em>engine</em> key represents the engine to be use for data validation. If the value is not provided the default value that is <em>ansible.uitls.jsonschema</em> will be used.</div>
|
||||
<div>The value should be in fully qualified collection name format that is <em><org-name>.<collection-name>.<validate-plugin-name></em>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -115,9 +115,9 @@ Examples
|
|||
.. code-block:: yaml
|
||||
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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 json format using jsonschema with test plugin
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyafter 2020 Red Hat
|
||||
# Copyright 2020 Red Hat
|
||||
# GNU General Public License v3.0+
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ __metaclass__ = type
|
|||
DOCUMENTATION = """
|
||||
author: Bradley Thornton (@cidrblock)
|
||||
name: json
|
||||
short_description: Define configurable options for C(json) sub-plugin of C(cli_parse) module
|
||||
short_description: Define configurable options for B(json) sub-plugin of B(cli_parse) module
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the I(ansible.utils.cli_parse) plugins when I(ansible.utils.json) is used as a value for
|
||||
to the M(ansible.utils.cli_parse) plugins when I(ansible.utils.json) is used as a value for
|
||||
I(name) option.
|
||||
version_added: 1.0.0
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@ EXAMPLES = r"""
|
|||
|
||||
- name: "Load text and parse with json"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', './nxos_show_interface_json_text.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', './nxos_show_interface_json_text.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.json
|
||||
register: nxos_json_text
|
||||
|
|
|
@ -11,10 +11,10 @@ __metaclass__ = type
|
|||
DOCUMENTATION = """
|
||||
author: Bradley Thornton (@cidrblock)
|
||||
name: textfsm
|
||||
short_description: Define configurable options for C(textfsm) sub-plugin of C(cli_parse) module
|
||||
short_description: Define configurable options for C(textfsm) sub-plugin of B(cli_parse) module
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the I(ansible.utils.cli_parse) plugins when I(ansible.utils.textfsm) is used as a value for
|
||||
to the M(ansible.utils.cli_parse) plugins when I(ansible.utils.textfsm) is used as a value for
|
||||
I(name) option.
|
||||
version_added: 1.0.0
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ EXAMPLES = r"""
|
|||
|
||||
- name: "Pass text and command"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '/home/user/files/nxos_show_version.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '/home/user/files/nxos_show_version.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.textfsm
|
||||
template_path: "/home/user/templates/nxos_show_version.textfsm"
|
||||
|
|
|
@ -11,10 +11,10 @@ __metaclass__ = type
|
|||
DOCUMENTATION = """
|
||||
author: Bradley Thornton (@cidrblock)
|
||||
name: ttp
|
||||
short_description: Define configurable options for C(ttp) sub-plugin of C(cli_parse) module
|
||||
short_description: Define configurable options for C(ttp) sub-plugin of B(cli_parse) module
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the I(ansible.utils.cli_parse) plugins when I(ansible.utils.ttp) is used as a value for
|
||||
to the M(ansible.utils.cli_parse) plugins when I(ansible.utils.ttp) is used as a value for
|
||||
I(name) option.
|
||||
version_added: 1.0.0
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ EXAMPLES = r"""
|
|||
|
||||
- name: "Pass text and command"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '/home/user/files/nxos_show_version.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '/home/user/files/nxos_show_version.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.textfsm
|
||||
template_path: "/home/user/templates/nxos_show_version.ttp"
|
||||
|
|
|
@ -11,10 +11,10 @@ __metaclass__ = type
|
|||
DOCUMENTATION = """
|
||||
author: Bradley Thornton (@cidrblock)
|
||||
name: xml
|
||||
short_description: Define configurable options for C(xml) sub-plugin of C(cli_parse) module
|
||||
short_description: Define configurable options for C(xml) sub-plugin of B(cli_parse) module
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the I(ansible.utils.cli_parse) plugins when I(ansible.utils.xml) is used as a value for
|
||||
to the M(ansible.utils.cli_parse) plugins when I(ansible.utils.xml) is used as a value for
|
||||
I(name) option.
|
||||
version_added: 1.0.0
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ EXAMPLES = r"""
|
|||
|
||||
- name: "Pass text and parse with xml"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '/home/user/files/nxos_show_interface.xml') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '/home/user/files/nxos_show_interface.xml') }}"
|
||||
parser:
|
||||
name: ansible.utils.xml
|
||||
os: nxos
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyafter 2020 Red Hat
|
||||
# Copyright 2020 Red Hat
|
||||
# GNU General Public License v3.0+
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -10,7 +10,7 @@ __metaclass__ = type
|
|||
DOCUMENTATION = """
|
||||
author: Bradley Thornton (@cidrblock)
|
||||
name: native
|
||||
short_description: Define configurable options for C(native) sub-plugin of C(fact_diff) module
|
||||
short_description: Define configurable options for C(native) sub-plugin of B(fact_diff) module
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the I(ansible.utils.fact_diff) plugins when I(ansible.utils.native) is used as a value for
|
||||
|
|
|
@ -17,21 +17,21 @@ DOCUMENTATION = """
|
|||
version_added: "1.0.0"
|
||||
short_description: Retrieve the value in a variable using a path
|
||||
description:
|
||||
- Use a C(path) to retrieve a nested value from a C(var).
|
||||
- C(get_path) is also available as a C(lookup plugin) for convenience.
|
||||
- Use a I(path) to retrieve a nested value from a I(var).
|
||||
- B(get_path) is also available as a B(lookup plugin) for convenience.
|
||||
- Using the parameters below- C(var|ansible.utils.get_path(path, wantlist))
|
||||
options:
|
||||
var:
|
||||
description:
|
||||
- The variable from which the value should be extracted.
|
||||
- This option represents the value that is passed to the filter plugin in pipe format.
|
||||
- For example I(config_data|ansible.utils.get_path()), in this case I(config_data) represents this option.
|
||||
- For example C(config_data|ansible.utils.get_path()), in this case B(config_data) represents this option.
|
||||
type: raw
|
||||
required: True
|
||||
path:
|
||||
description:
|
||||
- The C(path) in the C(var) to retrieve the value of.
|
||||
- The C(path) needs to be a valid jinja path.
|
||||
- The I(path) in the I(var) to retrieve the value of.
|
||||
- The I(path) needs to be a valid jinja path.
|
||||
type: str
|
||||
required: True
|
||||
wantlist:
|
||||
|
|
|
@ -19,14 +19,14 @@ DOCUMENTATION = """
|
|||
description:
|
||||
- This plugin returns the indices of items matching some criteria in a list.
|
||||
- When working with a list of dictionaries, the key to evaluate can be specified.
|
||||
- C(index_of) is also available as a C(lookup plugin) for convenience.
|
||||
- B(index_of) is also available as a B(lookup plugin) for convenience.
|
||||
- Using the parameters below- C(data|ansible.utils.index_of(test, value, key, fail_on_missing, wantlist))
|
||||
options:
|
||||
data:
|
||||
description:
|
||||
- A list of items to enumerate and test against.
|
||||
- This option represents the value that is passed to the filter plugin in pipe format.
|
||||
- For example I(config_data|ansible.utils.index_of('x')), in this case I(config_data) represents this option.
|
||||
- For example C(config_data|ansible.utils.index_of('x')), in this case B(config_data) represents this option.
|
||||
type: list
|
||||
required: True
|
||||
test:
|
||||
|
@ -40,20 +40,20 @@ DOCUMENTATION = """
|
|||
description:
|
||||
- The value used to test each list item against.
|
||||
- Not required for simple tests (eg: C(true), C(false), C(even), C(odd))
|
||||
- May be a C(string), C(boolean), C(number), C(regular expesion) C(dict) etc, depending on the C(test) used
|
||||
- May be a C(string), C(boolean), C(number), C(regular expression) C(dict) and so on, depending on the C(test) used
|
||||
type: raw
|
||||
key:
|
||||
description:
|
||||
- When the data provided is a list of dictionaries, run the test against this dictionary key.
|
||||
- When using a C(key), the C(data) must only contain dictionaries.
|
||||
- See C(fail_on_missing) below to determine the behavior when the C(key) is missing from a dictionary in the C(data).
|
||||
- When using a I(key), the I(data) must only contain dictionaries.
|
||||
- See I(fail_on_missing) below to determine the behavior when the I(key) is missing from a dictionary in the I(data).
|
||||
type: str
|
||||
fail_on_missing:
|
||||
description: When provided a list of dictionaries, fail if the key is missing from one or more of the dictionaries.
|
||||
type: bool
|
||||
wantlist:
|
||||
description:
|
||||
- When only a single entry in the C(data) is matched, the index of that entry is returned as an integer.
|
||||
- When only a single entry in the I(data) is matched, the index of that entry is returned as an integer.
|
||||
- If set to C(True), the return value will always be a list, even if only a single entry is matched.
|
||||
type: bool
|
||||
|
||||
|
@ -64,14 +64,15 @@ EXAMPLES = r"""
|
|||
|
||||
#### Simple examples
|
||||
|
||||
- set_fact:
|
||||
- name: Define a list
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -81,7 +82,7 @@ EXAMPLES = r"""
|
|||
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -92,7 +93,7 @@ EXAMPLES = r"""
|
|||
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of(test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -121,7 +122,8 @@ EXAMPLES = r"""
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- name: Define a list with hostname and type
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -133,7 +135,7 @@ EXAMPLES = r"""
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ data|ansible.utils.index_of('eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -189,7 +191,7 @@ EXAMPLES = r"""
|
|||
# name: mgmt0
|
||||
|
||||
- name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
found: "{{ found + entry }}"
|
||||
with_indexed_items: "{{ current_l3.gathered }}"
|
||||
vars:
|
||||
|
@ -223,7 +225,8 @@ EXAMPLES = r"""
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- name: Define interface configuration facts
|
||||
ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -20,19 +20,19 @@ DOCUMENTATION = """
|
|||
description:
|
||||
- Flatten a complex object into a dictionary of paths and values.
|
||||
- Paths are dot delimited whenever possible.
|
||||
- Brakets are used for list indices and keys that contain special characters.
|
||||
- C(to_paths) is also available as a C(lookup plugin) for convenience.
|
||||
- Brackets are used for list indices and keys that contain special characters.
|
||||
- B(to_paths) is also available as a B(lookup plugin) for convenience.
|
||||
- Using the parameters below- C(var|ansible.utils.to_paths(prepend, wantlist))
|
||||
options:
|
||||
var:
|
||||
description:
|
||||
- The value of C(var) will be will be used.
|
||||
- The value of I(var) will be will be used.
|
||||
- This option represents the value that is passed to the filter plugin in pipe format.
|
||||
- For example I(config_data|ansible.utils.to_paths()), in this case I(config_data) represents this option.
|
||||
- For example C(config_data|ansible.utils.to_paths()), in this case B(config_data) represents this option.
|
||||
type: raw
|
||||
required: True
|
||||
prepend:
|
||||
description: Prepend each path entry. Useful to add the initial C(var) name.
|
||||
description: Prepend each path entry. Useful to add the initial I(var) name.
|
||||
type: str
|
||||
required: False
|
||||
wantlist:
|
||||
|
@ -98,7 +98,7 @@ EXAMPLES = r"""
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Flatten the complex object
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ result.json|ansible.utils.to_paths }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -8,53 +8,53 @@ DOCUMENTATION = """
|
|||
version_added: "1.0.0"
|
||||
short_description: Validate data with provided criteria
|
||||
description:
|
||||
- Validate C(data) with provided C(criteria) based on the validation C(engine).
|
||||
- Validate I(data) with provided I(criteria) based on the validation I(engine).
|
||||
options:
|
||||
data:
|
||||
type: raw
|
||||
description:
|
||||
- Data that will be validated against C(criteria).
|
||||
- Data that will be validated against I(criteria).
|
||||
- This option represents the value that is passed to the filter plugin in pipe format.
|
||||
For example I(config_data|ansible.utils.validate()), in this case I(config_data)
|
||||
For example B(config_data|ansible.utils.validate()), in this case B(config_data)
|
||||
represents this option.
|
||||
- For the type of C(data) that represents this value refer to the documentation of individual validator plugins.
|
||||
- For the type of I(data) that represents this value refer to the documentation of individual validator plugins.
|
||||
required: True
|
||||
criteria:
|
||||
type: raw
|
||||
description:
|
||||
- The criteria used for validation of value that represents C(data) options.
|
||||
- The criteria used for validation of value that represents I(data) options.
|
||||
- This option represents the first argument passed in the filter plugin.
|
||||
For example I(config_data|ansible.utils.validate(config_criteria)), in
|
||||
this case the value of I(config_criteria) represents this option.
|
||||
- For the type of C(criteria) that represents this value refer to the documentation of individual validator plugins.
|
||||
For example B(config_data|ansible.utils.validate(config_criteria)), in
|
||||
this case the value of B(config_criteria) represents this option.
|
||||
- For the type of I(criteria) that represents this value refer to the documentation of individual validator plugins.
|
||||
required: True
|
||||
engine:
|
||||
type: str
|
||||
description:
|
||||
- The name of the validator plugin to use.
|
||||
- This option can be passed in lookup plugin as a key, value pair.
|
||||
For example I(config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema')), in
|
||||
this case the value I(ansible.utils.jsonschema) represents the engine to be use for data valdiation.
|
||||
If the value is not provided the default value that is I(ansible.uitls.jsonschema) will be used.
|
||||
For example C(config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema')), in
|
||||
this case the value C(ansible.utils.jsonschema) represents the engine to be use for data validation.
|
||||
If the value is not provided the default value that is C(ansible.uitls.jsonschema) will be used.
|
||||
- The value should be in fully qualified collection name format that is
|
||||
I(<org-name>.<collection-name>.<validator-plugin-name>).
|
||||
C(<org-name>.<collection-name>.<validator-plugin-name>).
|
||||
default: ansible.utils.jsonschema
|
||||
notes:
|
||||
- For the type of options C(data) and C(criteria) refer to the individual C(validate) plugin
|
||||
documentation that is represented in the value of C(engine) option.
|
||||
- For additional plugin configuration options refer to the individual C(validate) plugin
|
||||
documentation that is represented by the value of C(engine) option.
|
||||
- The plugin configuration option can be either passed as I(key=value) pairs within filter plugin
|
||||
- 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 B(key=value) pairs within filter plugin
|
||||
or environment variables.
|
||||
- The precedence of the C(validate) plugin configurable option is the variable passed within filter plugin
|
||||
as I(key=value) pairs followed by the environment variables.
|
||||
- The precedence of the I(validate) plugin configurable option is the variable passed within filter plugin
|
||||
as B(key=value) pairs followed by the environment variables.
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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 json format using jsonschema by passing plugin configuration variable as key/value pairs
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -18,8 +18,8 @@ DOCUMENTATION = """
|
|||
version_added: "1.0.0"
|
||||
short_description: Retrieve the value in a variable using a path
|
||||
description:
|
||||
- Use a C(path) to retrieve a nested value from a C(var)
|
||||
- C(get_path) is also available as a C(filter plugin) for convenience
|
||||
- Use a I(path) to retrieve a nested value from a I(var)
|
||||
- B(get_path) is also available as a B(filter plugin) for convenience
|
||||
- Using the parameters below- C(lookup('ansible.utils.get_path', var, path, wantlist))
|
||||
options:
|
||||
var:
|
||||
|
@ -28,14 +28,14 @@ DOCUMENTATION = """
|
|||
required: True
|
||||
path:
|
||||
description: >
|
||||
The C(path) in the C(var) to retrieve the value of.
|
||||
The C(path) needs to a be a valid jinja path.
|
||||
The I(path) in the I(var) to retrieve the value of.
|
||||
The I(path) needs to a be a valid jinja path.
|
||||
type: str
|
||||
required: True
|
||||
wantlist:
|
||||
description: >
|
||||
If set to C(True), the return value will always be a list.
|
||||
This can also be accomplished using C(query) or C(q) instead of C(lookup).
|
||||
This can also be accomplished using B(query) or B(q) instead of B(lookup).
|
||||
U(https://docs.ansible.com/ansible/latest/plugins/lookup.html).
|
||||
type: bool
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ DOCUMENTATION = """
|
|||
description:
|
||||
- This plugin returns the indices of items matching some criteria in a list.
|
||||
- When working with a list of dictionaries, the key to evaluate can be specified.
|
||||
- C(index_of) is also available as a C(filter plugin) for convenience.
|
||||
- B(index_of) is also available as a B(filter plugin) for convenience.
|
||||
- Using the parameters below- C(lookup('ansible.utils.index_of', data, test, value, key, fail_on_missing, wantlist)).
|
||||
options:
|
||||
data:
|
||||
|
@ -38,22 +38,22 @@ DOCUMENTATION = """
|
|||
description: >
|
||||
The value used to test each list item against.
|
||||
Not required for simple tests (eg: C(true), C(false), C(even), C(odd))
|
||||
May be a C(string), C(boolean), C(number), C(regular expesion) C(dict) etc, depending on the C(test) used.
|
||||
May be a C(string), C(boolean), C(number), C(regular expression) C(dict) and so on, depending on the B(test) used.
|
||||
type: raw
|
||||
key:
|
||||
description: >
|
||||
When the data provided is a list of dictionaries, run the test against this dictionary key.
|
||||
When using a C(key), the C(data) must only contain dictionaries.
|
||||
See C(fail_on_missing) below to determine the behaviour when the C(key) is missing from a dictionary in the C(data).
|
||||
When using a I(key), the I(data) must only contain dictionaries.
|
||||
See I(fail_on_missing) below to determine the behaviour when the I(key) is missing from a dictionary in the I(data).
|
||||
type: str
|
||||
fail_on_missing:
|
||||
description: When provided a list of dictionaries, fail if the key is missing from one or more of the dictionaries.
|
||||
type: bool
|
||||
wantlist:
|
||||
description: >
|
||||
When only a single entry in the C(data) is matched, the index of that entry is returned as an integer.
|
||||
When only a single entry in the I(data) is matched, the index of that entry is returned as an integer.
|
||||
If set to C(True), the return value will always be a list, even if only a single entry is matched.
|
||||
This can also be accomplised using C(query) or C(q) instead of C(lookup).
|
||||
This can also be accomplished using B(query) or B(q) instead of B(lookup).
|
||||
U(https://docs.ansible.com/ansible/latest/plugins/lookup.html)
|
||||
type: bool
|
||||
|
||||
|
@ -64,14 +64,14 @@ EXAMPLES = r"""
|
|||
|
||||
#### Simple examples
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -80,7 +80,7 @@ EXAMPLES = r"""
|
|||
# indices: '1'
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -90,7 +90,7 @@ EXAMPLES = r"""
|
|||
# - 1
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data=data, test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -134,7 +134,7 @@ EXAMPLES = r"""
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -146,7 +146,7 @@ EXAMPLES = r"""
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ lookup('ansible.utils.index_of', data, 'eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -202,7 +202,7 @@ EXAMPLES = r"""
|
|||
# name: mgmt0
|
||||
|
||||
- name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
found: "{{ found + entry }}"
|
||||
with_indexed_items: "{{ current_l3.gathered }}"
|
||||
vars:
|
||||
|
@ -236,7 +236,7 @@ EXAMPLES = r"""
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -21,21 +21,21 @@ DOCUMENTATION = """
|
|||
- Flatten a complex object into a dictionary of paths and values.
|
||||
- Paths are dot delimited whenever possible.
|
||||
- Brackets are used for list indices and keys that contain special characters.
|
||||
- C(to_paths) is also available as a filter plugin.
|
||||
- B(to_paths) is also available as a filter plugin.
|
||||
- Using the parameters below- C(lookup('ansible.utils.to_paths', var, prepend, wantlist))
|
||||
options:
|
||||
var:
|
||||
description: The value of C(var) will be will be used.
|
||||
description: The value of I(var) will be used.
|
||||
type: raw
|
||||
required: True
|
||||
prepend:
|
||||
description: Prepend each path entry. Useful to add the initial C(var) name.
|
||||
description: Prepend each path entry. Useful to add the initial I(var) name.
|
||||
type: str
|
||||
required: False
|
||||
wantlist:
|
||||
description: >
|
||||
If set to C(True), the return value will always be a list.
|
||||
This can also be accomplished using C(query) or C(q) instead of C(lookup).
|
||||
If set to I(True), the return value will always be a list.
|
||||
This can also be accomplished using B(query) or B(q) instead of B(lookup).
|
||||
U(https://docs.ansible.com/ansible/latest/plugins/lookup.html)
|
||||
type: bool
|
||||
|
||||
|
@ -86,7 +86,7 @@ EXAMPLES = r"""
|
|||
#### Using a complex object
|
||||
|
||||
- name: Make an API call
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "https://nxos101/restconf/data/openconfig-interfaces:interfaces"
|
||||
headers:
|
||||
accept: "application/yang.data+json"
|
||||
|
@ -97,7 +97,7 @@ EXAMPLES = r"""
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Flatten the complex object
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
paths: "{{ lookup('ansible.utils.to_paths', result.json) }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -13,25 +13,25 @@ DOCUMENTATION = """
|
|||
version_added: "1.0.0"
|
||||
short_description: Validate data with provided criteria
|
||||
description:
|
||||
- Validate C(data) with provided C(criteria) based on the validation C(engine).
|
||||
- Validate I(data) with provided I(criteria) based on the validation I(engine).
|
||||
options:
|
||||
data:
|
||||
type: raw
|
||||
description:
|
||||
- Data that will be validated against C(criteria).
|
||||
- Data that will be validated against I(criteria).
|
||||
- This option represents the value that is passed to the lookup plugin as the first argument.
|
||||
For example I(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')),
|
||||
in this case I(config_data) represents this option.
|
||||
- For the type of C(data) that represents this value refer to the documentation of individual validate plugins.
|
||||
For example C(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')),
|
||||
in this case B(config_data) represents this option.
|
||||
- For the type of I(data) that represents this value refer to the documentation of individual validate plugins.
|
||||
required: True
|
||||
criteria:
|
||||
type: raw
|
||||
description:
|
||||
- The criteria used for validation of value that represents C(data) options.
|
||||
- The criteria used for validation of value that represents I(data) options.
|
||||
- This option represents the second argument passed in the lookup plugin
|
||||
For example I(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')),
|
||||
in this case the value of I(config_criteria) represents this option.
|
||||
- For the type of C(criteria) that represents this value refer to the documentation of individual
|
||||
For example C(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')),
|
||||
in this case the value of B(config_criteria) represents this option.
|
||||
- For the type of I(criteria) that represents this value refer to the documentation of individual
|
||||
validate plugins.
|
||||
required: True
|
||||
engine:
|
||||
|
@ -39,28 +39,28 @@ DOCUMENTATION = """
|
|||
description:
|
||||
- The name of the validate plugin to use.
|
||||
- This option can be passed in lookup plugin as a key, value pair.
|
||||
For example I(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')), in
|
||||
this case the value I(ansible.utils.jsonschema) represents the engine to be use for data valdiation.
|
||||
If the value is not provided the default value that is I(ansible.uitls.jsonschema) will be used.
|
||||
For example C(lookup(config_data, config_criteria, engine='ansible.utils.jsonschema')), in
|
||||
this case the value C(ansible.utils.jsonschema) represents the engine to be use for data validation.
|
||||
If the value is not provided the default value that is C(ansible.uitls.jsonschema) will be used.
|
||||
- The value should be in fully qualified collection name format that is
|
||||
I(<org-name>.<collection-name>.<validate-plugin-name>).
|
||||
C(<org-name>.<collection-name>.<validate-plugin-name>).
|
||||
default: ansible.utils.jsonschema
|
||||
notes:
|
||||
- For the type of options C(data) and C(criteria) refer to the individual C(validate) plugin
|
||||
documentation that is represented in the value of C(engine) option.
|
||||
- For additional plugin configuration options refer to the individual C(validate) plugin
|
||||
documentation that is represented by the value of C(engine) option.
|
||||
- The plugin configuration option can be either passed as I(key=value) pairs within lookup plugin
|
||||
- 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 B(key=value) pairs within lookup plugin
|
||||
or task or environment variables.
|
||||
- The precedence the C(validate) plugin configurable option is the variable passed within lookup plugin
|
||||
as I(key=value) pairs followed by task variables followed by environment variables.
|
||||
- The precedence the validate plugin configurable option is the variable passed within lookup plugin
|
||||
as B(key=value) pairs followed by task variables followed by environment variables.
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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 json format using jsonschema with lookup plugin by passing plugin configuration variable as key/value pairs
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyafter 2020 Red Hat
|
||||
# Copyright 2020 Red Hat
|
||||
# GNU General Public License v3.0+
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ notes:
|
|||
- The default Ansible search path for the templates directory is used for parser templates as well
|
||||
- Some parsers may have additional configuration options available. See the parsers/vars key and the parser's documentation
|
||||
- Some parsers require third-party python libraries be installed on the Ansible control node and a specific python version
|
||||
- e.g. Pyats requires pyats and genie and requires Python 3
|
||||
- e.g. ntc_templates requires ntc_templates
|
||||
- e.g. textfsm requires textfsm
|
||||
- e.g. ttp requires ttp
|
||||
- e.g. xml requires xml_to_dict
|
||||
- example Pyats requires pyats and genie and requires Python 3
|
||||
- example ntc_templates requires ntc_templates
|
||||
- example textfsm requires textfsm
|
||||
- example ttp requires ttp
|
||||
- example xml requires xml_to_dict
|
||||
- Support of 3rd party python libraries is limited to the use of their public APIs as documented
|
||||
- "Additional information and examples can be found in the parsing user guide:"
|
||||
- https://docs.ansible.com/ansible/latest/network/user_guide/cli_parsing.html
|
||||
|
@ -133,7 +133,7 @@ EXAMPLES = r"""
|
|||
# -------------
|
||||
# The ntc_templates use 'vendor_platform' for the file name
|
||||
# it will be derived from ansible_network_os if not provided
|
||||
# e.g. cisco.ios.ios => cisco_ios
|
||||
# example cisco.ios.ios => cisco_ios
|
||||
|
||||
- name: Run command and parse with ntc_templates
|
||||
ansible.utils.cli_parse:
|
||||
|
@ -276,5 +276,6 @@ stdout_lines:
|
|||
description: The output of the command run split into lines
|
||||
returned: when provided a command
|
||||
type: list
|
||||
elements: str
|
||||
sample:
|
||||
"""
|
||||
|
|
|
@ -51,6 +51,7 @@ options:
|
|||
- If the provided I(before) and I(after) are a string, they will be split.
|
||||
- Each entry in each list will be cast to a string for the comparison
|
||||
type: list
|
||||
elements: str
|
||||
|
||||
notes:
|
||||
|
||||
|
@ -59,7 +60,7 @@ author:
|
|||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
before:
|
||||
a:
|
||||
b:
|
||||
|
@ -198,8 +199,9 @@ diff_text:
|
|||
returned: always
|
||||
type: str
|
||||
diff_lines:
|
||||
description: The C(diff_text) split into lines.
|
||||
description: The I(diff_text) split into lines.
|
||||
returned: always
|
||||
type: list
|
||||
elements: str
|
||||
|
||||
"""
|
||||
|
|
|
@ -51,7 +51,7 @@ EXAMPLES = r"""
|
|||
|
||||
# Update an exisitng fact, dot or bracket notation
|
||||
- name: Set a fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -82,7 +82,7 @@ EXAMPLES = r"""
|
|||
# Lists can be appended, new keys added to dictionaries
|
||||
|
||||
- name: Set a fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
b1:
|
||||
|
@ -124,7 +124,7 @@ EXAMPLES = r"""
|
|||
#####################################################################
|
||||
|
||||
- name: Set fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
addresses:
|
||||
- raw: 10.1.1.0/255.255.255.0
|
||||
name: servers
|
||||
|
@ -134,7 +134,7 @@ EXAMPLES = r"""
|
|||
name: dns
|
||||
|
||||
- name: Build a list of updates
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
update_list: "{{ update_list + update }}"
|
||||
loop: "{{ addresses }}"
|
||||
loop_control:
|
||||
|
@ -291,7 +291,7 @@ EXAMPLES = r"""
|
|||
- l3_interfaces
|
||||
|
||||
- name: Build the list of updates to make
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
updates: "{{ updates + [entry] }}"
|
||||
vars:
|
||||
updates: []
|
||||
|
|
|
@ -22,7 +22,7 @@ options:
|
|||
data:
|
||||
type: raw
|
||||
description:
|
||||
- Data that will be validated against C(criteria). For the type of data refer to the
|
||||
- Data that will be validated against I(criteria). For the type of data refer to the
|
||||
documentation of individual validate plugins.
|
||||
required: True
|
||||
engine:
|
||||
|
@ -35,24 +35,24 @@ options:
|
|||
criteria:
|
||||
type: raw
|
||||
description:
|
||||
- The criteria used for validation of C(data). For the type of criteria refer to the
|
||||
- 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 C(data) and C(criteria) refer to the individual C(validate) plugin
|
||||
documentation that is represented in the value of C(engine) option.
|
||||
- For additional plugin configuration options refer to the individual C(validate) plugin
|
||||
documentation that is represented by the value of C(engine) option.
|
||||
- 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 C(validate) plugin configurable option is task variables followed
|
||||
- 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
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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:
|
||||
|
@ -66,14 +66,15 @@ EXAMPLES = r"""
|
|||
RETURN = r"""
|
||||
msg:
|
||||
description:
|
||||
- The msg indicates if the C(data) is valid as per the C(criteria).
|
||||
- In case data is valid return success message I(all checks passed).
|
||||
- In case data is invalid return error message I(Validation errors were found)
|
||||
- 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 C(data) based on the C(criteria).
|
||||
returned: when C(data) value is invalid
|
||||
description: The list of errors in I(data) based on the I(criteria).
|
||||
returned: when I(data) value is invalid
|
||||
type: list
|
||||
elements: str
|
||||
"""
|
||||
|
|
|
@ -12,53 +12,53 @@ DOCUMENTATION = """
|
|||
version_added: "1.0.0"
|
||||
short_description: Validate data with provided criteria
|
||||
description:
|
||||
- Validate C(data) with provided C(criteria) based on the validation C(engine).
|
||||
- Validate I(data) with provided I(criteria) based on the validation I(engine).
|
||||
options:
|
||||
data:
|
||||
type: raw
|
||||
description:
|
||||
- A data that will be validated against C(criteria).
|
||||
- A data that will be validated against I(criteria).
|
||||
- This option represents the value that is passed to test plugin as check.
|
||||
For example I(config_data is ansible.utils.validate(criteria=criteria), in this case I(config_data)
|
||||
For example C(config_data is ansible.utils.validate(criteria=criteria), in this case B(config_data)
|
||||
represents this option.
|
||||
- For the type of C(data) that represents this value refer documentation of individual validate plugins.
|
||||
- For the type of I(data) that represents this value refer documentation of individual validate plugins.
|
||||
required: True
|
||||
criteria:
|
||||
type: raw
|
||||
description:
|
||||
- The criteria used for validation of value that represents C(data) options.
|
||||
- The criteria used for validation of value that represents I(data) options.
|
||||
- This option is passed to the test plugin as key, value pair
|
||||
For example I(config_data is ansible.utils.validate(criteria=criteria)), in
|
||||
For example C(config_data is ansible.utils.validate(criteria=criteria)), in
|
||||
this case the value of I(criteria) key represents this criteria for data validation.
|
||||
- For the type of C(criteria) that represents this value refer documentation of individual validate plugins.
|
||||
- For the type of I(criteria) that represents this value refer documentation of individual validate plugins.
|
||||
required: True
|
||||
engine:
|
||||
type: str
|
||||
description:
|
||||
- The name of the validate plugin to use.
|
||||
- This option can be passed in test plugin as a key, value pair
|
||||
For example I(config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria)), in
|
||||
this case the value of I(engine) key represents the engine to be use for data valdiation.
|
||||
If the value is not provided the default value that is I(ansible.uitls.jsonschema) will be used.
|
||||
For example C(config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria)), in
|
||||
this case the value of I(engine) key represents the engine to be use for data validation.
|
||||
If the value is not provided the default value that is B(ansible.uitls.jsonschema) will be used.
|
||||
- The value should be in fully qualified collection name format that is
|
||||
I(<org-name>.<collection-name>.<validate-plugin-name>).
|
||||
B(<org-name>.<collection-name>.<validate-plugin-name>).
|
||||
default: ansible.utils.jsonschema
|
||||
notes:
|
||||
- For the type of options C(data) and C(criteria) refer the individual C(validate) plugin
|
||||
documentation that is represented in the value of C(engine) option.
|
||||
- For additional plugin configuration options refer the individual C(validate) plugin
|
||||
documentation that is represented by the value of C(engine) option.
|
||||
- The plugin configuration option can be either passed as I(key=value) pairs within test plugin
|
||||
- For the type of options I(data) and I(criteria) refer the individual validate plugin
|
||||
documentation that is represented in the value of I(engine) option.
|
||||
- For additional plugin configuration options refer the individual validate plugin
|
||||
documentation that is represented by the value of I(engine) option.
|
||||
- The plugin configuration option can be either passed as B(key=value) pairs within test plugin
|
||||
or set as environment variables.
|
||||
- The precedence the C(validate) plugin configurable option is the variable passed within test plugin
|
||||
as I(key=value) pairs followed by task variables followed by environment variables.
|
||||
- The precedence the validate plugin configurable option is the variable passed within test plugin
|
||||
as B(key=value) pairs followed by task variables followed by environment variables.
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: set facts for data and criteria
|
||||
set_fact:
|
||||
data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}"
|
||||
criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}"
|
||||
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 json format using jsonschema with test plugin
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -13,15 +13,15 @@ DOCUMENTATION = """
|
|||
short_description: Define configurable options for jsonschema validate plugin
|
||||
description:
|
||||
- This plugin documentation provides the configurable options that can be passed
|
||||
to the validate plugins when I(ansible.utils.json) is used as a value for
|
||||
to the validate plugins when C(ansible.utils.jsonschema) is used as a value for
|
||||
engine option.
|
||||
version_added: 1.0.0
|
||||
options:
|
||||
draft:
|
||||
description:
|
||||
- This option provides the jsonschema specification that should be used
|
||||
for the validating the data. The C(criteria) option in the C(validate)
|
||||
plugin should follow the specifiaction as mentined by this option
|
||||
for the validating the data. The I(criteria) option in the validate
|
||||
plugin should follow the specification as mentioned by this option
|
||||
default: draft7
|
||||
choices:
|
||||
- draft3
|
||||
|
@ -33,10 +33,10 @@ DOCUMENTATION = """
|
|||
vars:
|
||||
- name: ansible_validate_jsonschema_draft
|
||||
notes:
|
||||
- The value of C(data) option should be either of type I(dict) or I(strings) which should be
|
||||
a valid I(dict) when read in python.
|
||||
- The value of C(criteria) should be I(list) of I(dict) or I(list) of I(strings) and each
|
||||
I(string) within the I(list) entry should be a valid I(dict) when read in python.
|
||||
- The value of I(data) option should be either of type B(dict) or B(strings) which should be
|
||||
a valid B(dict) when read in python.
|
||||
- The value of I(criteria) should be B(list) of B(dict) or B(list) of B(strings) and each
|
||||
B(string) within the B(list) entry should be a valid B(dict) when read in python.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: Set a short name
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
os: "{{ ansible_distribution|d }}"
|
||||
|
||||
- include_tasks: argspec.yaml
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- set_fact:
|
||||
nxos_json_text_parsed: "{{ lookup('file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||
- ansible.builtin.set_fact:
|
||||
nxos_json_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||
|
||||
- name: "{{ parser }} Run command and parse with json"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.json
|
||||
register: nxos_json_text
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- set_fact:
|
||||
nxos_textfsm_text_parsed: "{{ lookup('file', '{{ role_path }}/output/nxos_show_version_textfsm_parsed.json') | from_json }}"
|
||||
- ansible.builtin.set_fact:
|
||||
nxos_textfsm_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_version_textfsm_parsed.json') | from_json }}"
|
||||
|
||||
- name: "{{ parser }} Pass text and command"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/files/nxos_show_version.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_version.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.textfsm
|
||||
template_path: "{{ role_path }}/templates/nxos_show_version.textfsm"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- set_fact:
|
||||
nxos_ttp_text_parsed: "{{ lookup('file', '{{ role_path }}/output/nxos_show_interface_ttp_parsed.json') | from_json }}"
|
||||
- ansible.builtin.set_fact:
|
||||
nxos_ttp_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_ttp_parsed.json') | from_json }}"
|
||||
|
||||
- name: "{{ parser }} Pass text and template_path"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.ttp
|
||||
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
- name: "{{ parser }} Pass text and custom variable"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.ttp
|
||||
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
- name: "{{ parser }} Pass text and ttp_results modified"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||
parser:
|
||||
name: ansible.utils.ttp
|
||||
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- set_fact:
|
||||
nxos_xml_text_parsed: "{{ lookup('file', '{{ role_path }}/output/nxos_show_interface_xml_parsed.json') | from_json }}"
|
||||
- ansible.builtin.set_fact:
|
||||
nxos_xml_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_xml_parsed.json') | from_json }}"
|
||||
|
||||
- name: "{{ parser }} Pass text and parse with xml"
|
||||
ansible.utils.cli_parse:
|
||||
text: "{{ lookup('file', '{{ role_path }}/files/nxos_show_interface.xml') }}"
|
||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.xml') }}"
|
||||
parser:
|
||||
name: ansible.utils.xml
|
||||
os: nxos
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
before:
|
||||
a:
|
||||
b:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -8,7 +8,7 @@
|
|||
- 1
|
||||
|
||||
- name: Check argspec validation with filter
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ a|ansible.utils.get_path() }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -19,7 +19,7 @@
|
|||
msg: "missing required arguments: path"
|
||||
|
||||
- name: Check argspec validation with lookup
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ lookup('ansible.utils.get_path') }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -40,7 +40,7 @@
|
|||
- result: "{{ lookup('ansible.utils.get_path', a, 'b[\"c\"]') }}"
|
||||
expected: "{{ a.b.c }}"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
complex:
|
||||
a:
|
||||
b:
|
||||
|
@ -12,7 +12,7 @@
|
|||
e1: redhat
|
||||
|
||||
- name: Check argspec validation with filter (not a list)
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ complex|ansible.utils.index_of() }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -23,7 +23,7 @@
|
|||
msg: "cannot be converted to a list"
|
||||
|
||||
- name: Check argspec validation with filter (missing params)
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ complex.a.b.c.d|ansible.utils.index_of() }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -34,7 +34,7 @@
|
|||
msg: "missing required arguments: test"
|
||||
|
||||
- name: Check argspec validation with lookup (not a list)
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ lookup('ansible.utils.index_of', complex) }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -45,7 +45,7 @@
|
|||
msg: "cannot be converted to a list"
|
||||
|
||||
- name: Check argspec validation with lookup (missing params)
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ lookup('ansible.utils.index_of') }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
---
|
||||
#### Simple examples
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -16,7 +16,7 @@
|
|||
# indices: '1'
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of('eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -26,7 +26,7 @@
|
|||
# - 1
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ data|ansible.utils.index_of(test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -66,7 +66,7 @@
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ data|ansible.utils.index_of('eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -122,7 +122,7 @@
|
|||
# name: mgmt0
|
||||
|
||||
# - name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
# set_fact:
|
||||
# ansible.builtin.set_fact:
|
||||
# found: "{{ found + entry }}"
|
||||
# with_indexed_items: "{{ current_l3.gathered }}"
|
||||
# vars:
|
||||
|
@ -156,7 +156,7 @@
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
---
|
||||
#### Simple examples
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
- name: Find the index of 2
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2) }}"
|
||||
|
||||
# TASK [Find the index of 2] *************************************************
|
||||
|
@ -16,7 +16,7 @@
|
|||
# indices: '1'
|
||||
|
||||
- name: Find the index of 2, ensure list is returned
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2, wantlist=True) }}"
|
||||
|
||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||
|
@ -26,7 +26,7 @@
|
|||
# - 1
|
||||
|
||||
- name: Find the index of 3 using the long format
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
indices: "{{ lookup('ansible.utils.index_of', data=data, test='eq', value=value, wantlist=True) }}"
|
||||
vars:
|
||||
value: 3
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
#### Working with lists of dictionaries
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
- name: sw01.example.lan
|
||||
type: switch
|
||||
|
@ -82,7 +82,7 @@
|
|||
type: firewall
|
||||
|
||||
- name: Find the index of all firewalls using the type key
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
firewalls: "{{ lookup('ansible.utils.index_of', data, 'eq', 'firewall', 'type') }}"
|
||||
|
||||
# TASK [Find the index of all firewalls using the type key] ******************
|
||||
|
@ -138,7 +138,7 @@
|
|||
# name: mgmt0
|
||||
|
||||
# - name: Find the indices interfaces with a 192.168.101.xx ip address
|
||||
# set_fact:
|
||||
# ansible.builtin.set_fact:
|
||||
# found: "{{ found + entry }}"
|
||||
# with_indexed_items: "{{ current_l3.gathered }}"
|
||||
# vars:
|
||||
|
@ -172,7 +172,7 @@
|
|||
|
||||
#### Working with deeply nested data
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
data:
|
||||
interfaces:
|
||||
interface:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
complex:
|
||||
a:
|
||||
- true
|
||||
|
@ -58,7 +58,7 @@
|
|||
result: [0, 1]
|
||||
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
complex:
|
||||
a:
|
||||
b:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -7,7 +7,7 @@
|
|||
- 0
|
||||
|
||||
- name: Check argspec validation with lookup
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ a|ansible.utils.to_paths(wantlist=5) }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
|
||||
- name: Check argspec validation with lookup
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
_result: "{{ lookup('ansible.utils.to_paths') }}"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#### Using a complex object
|
||||
|
||||
# - name: Make an API call
|
||||
# uri:
|
||||
# ansible.builtin.uri:
|
||||
# url: "https://nxos101/restconf/data/openconfig-interfaces:interfaces"
|
||||
# headers:
|
||||
# accept: "application/yang.data+json"
|
||||
|
@ -51,7 +51,7 @@
|
|||
# delegate_to: localhost
|
||||
|
||||
# - name: Flatten the complex object
|
||||
# set_fact:
|
||||
# ansible.builtin.set_fact:
|
||||
# paths: "{{ result.json|ansible.utils.to_paths }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#### Using a complex object
|
||||
|
||||
# - name: Make an API call
|
||||
# uri:
|
||||
# ansible.builtin.uri:
|
||||
# url: "https://nxos101/restconf/data/openconfig-interfaces:interfaces"
|
||||
# headers:
|
||||
# accept: "application/yang.data+json"
|
||||
|
@ -51,7 +51,7 @@
|
|||
# delegate_to: localhost
|
||||
|
||||
# - name: Flatten the complex object
|
||||
# set_fact:
|
||||
# ansible.builtin.set_fact:
|
||||
# paths: "{{ lookup('ansible.utils.to_paths', result.json) }}"
|
||||
|
||||
# TASK [Flatten the complex object] ******************************************
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
@ -28,7 +28,7 @@
|
|||
a.b.c.d[0]: 0
|
||||
a.b.c.d[1]: 1
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- name: Set a fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
a:
|
||||
b:
|
||||
c:
|
||||
|
|
|
@ -62,12 +62,12 @@
|
|||
- "'\\'criteria\\' option value is invalid, value should of type dict or str format of dict' in result.msg"
|
||||
|
||||
- name: read data and criteria from file
|
||||
set_fact:
|
||||
data: "{{ lookup('file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('file', 'criteria/in_rate_check.json') }}"
|
||||
ansible.builtin.set_fact:
|
||||
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
|
||||
|
||||
- name: validate data using jsonschema engine (invalid data read from file)
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -80,12 +80,12 @@
|
|||
- "'\\'criteria\\' option value is invalid, value should of type dict or str format of dict' in result.msg"
|
||||
|
||||
- name: read data and criteria from file
|
||||
set_fact:
|
||||
data: "{{ lookup('file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('file', 'criteria/in_rate_check.json') }}"
|
||||
ansible.builtin.set_fact:
|
||||
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
|
||||
|
||||
- name: validate data using jsonschema engine (invalid data read from file)
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -96,11 +96,11 @@
|
|||
|
||||
- name: validate data using jsonschema engine (invalid data read from file)
|
||||
ansible.utils.validate:
|
||||
data: "{{ lookup('file', 'data/show_interface.json') }}"
|
||||
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
|
||||
criteria:
|
||||
- "{{ lookup('file', 'criteria/oper_status_up.json') }}"
|
||||
- "{{ lookup('file', 'criteria/enabled_check.json') }}"
|
||||
- "{{ lookup('file', 'criteria/crc_error_check.json') }}"
|
||||
- "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
|
||||
- "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
|
||||
- "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
|
||||
engine: ansible.utils.jsonschema
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
@ -120,8 +120,8 @@
|
|||
|
||||
- name: validate data using jsonschema engine (valid data read from file)
|
||||
ansible.utils.validate:
|
||||
data: "{{ lookup('file', 'data/show_interface.json') }}"
|
||||
criteria: "{{ lookup('file', 'criteria/in_rate_check.json') }}"
|
||||
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
|
||||
criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
|
||||
engine: ansible.utils.jsonschema
|
||||
ignore_errors: true
|
||||
register: result
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
- "'\\'criteria\\' option value is invalid, value should of type dict or str format of dict' in result.msg"
|
||||
|
||||
- name: read data and criteria from file
|
||||
set_fact:
|
||||
data: "{{ lookup('file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('file', 'criteria/in_rate_check.json') }}"
|
||||
ansible.builtin.set_fact:
|
||||
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
|
||||
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
|
||||
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
|
||||
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
|
||||
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
|
||||
|
||||
- name: validate data using jsonschema engine (invalid data read from file)
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyafter 2020 Red Hat
|
||||
# Copyright 2020 Red Hat
|
||||
# GNU General Public License v3.0+
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyafter 2020 Red Hat
|
||||
# Copyright 2020 Red Hat
|
||||
# GNU General Public License v3.0+
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
|
Loading…
Reference in New Issue