diff --git a/README.md b/README.md index 364ae28..80494ed 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,14 @@ Please read and familiarize yourself with this document. ## Release notes 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. diff --git a/changelogs/fragments/32_doc_updates.yaml b/changelogs/fragments/32_doc_updates.yaml new file mode 100644 index 0000000..7fb7e17 --- /dev/null +++ b/changelogs/fragments/32_doc_updates.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Ansible 3.0.0 collection inclusion related changes (https://github.com/ansible-collections/ansible-inclusion/discussions/4) diff --git a/docs/ansible.utils.cli_parse_module.rst b/docs/ansible.utils.cli_parse_module.rst index c33a9c1..162f404 100644 --- a/docs/ansible.utils.cli_parse_module.rst +++ b/docs/ansible.utils.cli_parse_module.rst @@ -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: diff --git a/docs/ansible.utils.fact_diff_module.rst b/docs/ansible.utils.fact_diff_module.rst index 263fe70..4aa9f30 100644 --- a/docs/ansible.utils.fact_diff_module.rst +++ b/docs/ansible.utils.fact_diff_module.rst @@ -148,7 +148,7 @@ Examples .. code-block:: yaml - - set_fact: + - ansible.builtin.set_fact: before: a: b: diff --git a/docs/ansible.utils.index_of_filter.rst b/docs/ansible.utils.index_of_filter.rst index ea97ebf..2e3135b 100644 --- a/docs/ansible.utils.index_of_filter.rst +++ b/docs/ansible.utils.index_of_filter.rst @@ -133,7 +133,7 @@ Parameters
The value used to test each list item against.
{'Not required for simple tests (eg': 'true, false, even, odd)'}
-
May be a string, boolean, number, regular expesion dict etc, depending on the test used
+
May be a string, boolean, number, regular expression dict and so on, depending on the test used
@@ -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: diff --git a/docs/ansible.utils.index_of_lookup.rst b/docs/ansible.utils.index_of_lookup.rst index b741203..00d8060 100644 --- a/docs/ansible.utils.index_of_lookup.rst +++ b/docs/ansible.utils.index_of_lookup.rst @@ -125,7 +125,7 @@ Parameters -
The value used to test each list item against. Not required for simple tests (eg: true, false, even, odd) May be a string, boolean, number, regular expesion dict etc, depending on the test used.
+
The value used to test each list item against. Not required for simple tests (eg: true, false, even, odd) May be a string, boolean, number, regular expression dict and so on, depending on the test used.
@@ -146,7 +146,7 @@ Parameters -
When only a single entry in the data is matched, the index of that entry is returned as an integer. If set to True, the return value will always be a list, even if only a single entry is matched. This can also be accomplised using query or q instead of lookup. https://docs.ansible.com/ansible/latest/plugins/lookup.html
+
When only a single entry in the data is matched, the index of that entry is returned as an integer. If set to True, the return value will always be a list, even if only a single entry is matched. This can also be accomplished using query or q instead of lookup. https://docs.ansible.com/ansible/latest/plugins/lookup.html
@@ -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: diff --git a/docs/ansible.utils.to_paths_filter.rst b/docs/ansible.utils.to_paths_filter.rst index d573443..ae6c740 100644 --- a/docs/ansible.utils.to_paths_filter.rst +++ b/docs/ansible.utils.to_paths_filter.rst @@ -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] ****************************************** diff --git a/docs/ansible.utils.to_paths_lookup.rst b/docs/ansible.utils.to_paths_lookup.rst index a8ae00f..7d7fde2 100644 --- a/docs/ansible.utils.to_paths_lookup.rst +++ b/docs/ansible.utils.to_paths_lookup.rst @@ -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] ****************************************** diff --git a/docs/ansible.utils.update_fact_module.rst b/docs/ansible.utils.update_fact_module.rst index 5d2cd78..675cbc4 100644 --- a/docs/ansible.utils.update_fact_module.rst +++ b/docs/ansible.utils.update_fact_module.rst @@ -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: [] diff --git a/docs/ansible.utils.validate_filter.rst b/docs/ansible.utils.validate_filter.rst index 566d916..2fd99d1 100644 --- a/docs/ansible.utils.validate_filter.rst +++ b/docs/ansible.utils.validate_filter.rst @@ -90,7 +90,7 @@ Parameters
The name of the validator plugin to use.
-
This option can be passed in lookup plugin as a key, value pair. For example config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema'), in this case the value ansible.utils.jsonschema represents the engine to be use for data valdiation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
+
This option can be passed in lookup plugin as a key, value pair. For example config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema'), in this case the value ansible.utils.jsonschema represents the engine to be use for data validation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
The value should be in fully qualified collection name format that is <org-name>.<collection-name>.<validator-plugin-name>.
@@ -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: diff --git a/docs/ansible.utils.validate_lookup.rst b/docs/ansible.utils.validate_lookup.rst index ff4293d..583c890 100644 --- a/docs/ansible.utils.validate_lookup.rst +++ b/docs/ansible.utils.validate_lookup.rst @@ -90,7 +90,7 @@ Parameters
The name of the validate plugin to use.
-
This option can be passed in lookup plugin as a key, value pair. For example lookup(config_data, config_criteria, engine='ansible.utils.jsonschema'), in this case the value ansible.utils.jsonschema represents the engine to be use for data valdiation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
+
This option can be passed in lookup plugin as a key, value pair. For example lookup(config_data, config_criteria, engine='ansible.utils.jsonschema'), in this case the value ansible.utils.jsonschema represents the engine to be use for data validation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
The value should be in fully qualified collection name format that is <org-name>.<collection-name>.<validate-plugin-name>.
@@ -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: diff --git a/docs/ansible.utils.validate_module.rst b/docs/ansible.utils.validate_module.rst index 64cdb4b..e9acd7e 100644 --- a/docs/ansible.utils.validate_module.rst +++ b/docs/ansible.utils.validate_module.rst @@ -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: diff --git a/docs/ansible.utils.validate_test.rst b/docs/ansible.utils.validate_test.rst index 7e6010b..11b1de6 100644 --- a/docs/ansible.utils.validate_test.rst +++ b/docs/ansible.utils.validate_test.rst @@ -90,7 +90,7 @@ Parameters
The name of the validate plugin to use.
-
This option can be passed in test plugin as a key, value pair For example config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria), in this case the value of engine key represents the engine to be use for data valdiation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
+
This option can be passed in test plugin as a key, value pair For example config_data is ansible.utils.validate(engine='ansible.utils.jsonschema', criteria=criteria), in this case the value of engine key represents the engine to be use for data validation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
The value should be in fully qualified collection name format that is <org-name>.<collection-name>.<validate-plugin-name>.
@@ -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: diff --git a/plugins/action/fact_diff.py b/plugins/action/fact_diff.py index 444c33b..0149866 100644 --- a/plugins/action/fact_diff.py +++ b/plugins/action/fact_diff.py @@ -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) diff --git a/plugins/cli_parsers/json_parser.py b/plugins/cli_parsers/json_parser.py index adb16e5..6608825 100644 --- a/plugins/cli_parsers/json_parser.py +++ b/plugins/cli_parsers/json_parser.py @@ -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 diff --git a/plugins/cli_parsers/textfsm_parser.py b/plugins/cli_parsers/textfsm_parser.py index 27a93c7..ebdfc0c 100644 --- a/plugins/cli_parsers/textfsm_parser.py +++ b/plugins/cli_parsers/textfsm_parser.py @@ -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" diff --git a/plugins/cli_parsers/ttp_parser.py b/plugins/cli_parsers/ttp_parser.py index 6785c6a..0ee580d 100644 --- a/plugins/cli_parsers/ttp_parser.py +++ b/plugins/cli_parsers/ttp_parser.py @@ -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" diff --git a/plugins/cli_parsers/xml_parser.py b/plugins/cli_parsers/xml_parser.py index fb8d320..633f632 100644 --- a/plugins/cli_parsers/xml_parser.py +++ b/plugins/cli_parsers/xml_parser.py @@ -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 diff --git a/plugins/fact_diff/native.py b/plugins/fact_diff/native.py index 32bbe5e..61395e8 100644 --- a/plugins/fact_diff/native.py +++ b/plugins/fact_diff/native.py @@ -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 diff --git a/plugins/filter/get_path.py b/plugins/filter/get_path.py index 7796cd6..8b9d5a6 100644 --- a/plugins/filter/get_path.py +++ b/plugins/filter/get_path.py @@ -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: diff --git a/plugins/filter/index_of.py b/plugins/filter/index_of.py index d46298e..6afbd01 100644 --- a/plugins/filter/index_of.py +++ b/plugins/filter/index_of.py @@ -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: diff --git a/plugins/filter/to_paths.py b/plugins/filter/to_paths.py index 14d59c3..ddc247e 100644 --- a/plugins/filter/to_paths.py +++ b/plugins/filter/to_paths.py @@ -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] ****************************************** diff --git a/plugins/filter/validate.py b/plugins/filter/validate.py index fa0c443..2086c47 100644 --- a/plugins/filter/validate.py +++ b/plugins/filter/validate.py @@ -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(..). + C(..). 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: diff --git a/plugins/lookup/get_path.py b/plugins/lookup/get_path.py index bd32d77..922680d 100644 --- a/plugins/lookup/get_path.py +++ b/plugins/lookup/get_path.py @@ -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 diff --git a/plugins/lookup/index_of.py b/plugins/lookup/index_of.py index 8ac34b3..abb6ca6 100644 --- a/plugins/lookup/index_of.py +++ b/plugins/lookup/index_of.py @@ -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: diff --git a/plugins/lookup/to_paths.py b/plugins/lookup/to_paths.py index a8c66d2..342ac0e 100644 --- a/plugins/lookup/to_paths.py +++ b/plugins/lookup/to_paths.py @@ -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] ****************************************** diff --git a/plugins/lookup/validate.py b/plugins/lookup/validate.py index 80c66f2..2ff4059 100644 --- a/plugins/lookup/validate.py +++ b/plugins/lookup/validate.py @@ -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(..). + C(..). 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: diff --git a/plugins/module_utils/base_classes/fact_diff.py b/plugins/module_utils/base_classes/fact_diff.py index 10766e4..a01b3d1 100644 --- a/plugins/module_utils/base_classes/fact_diff.py +++ b/plugins/module_utils/base_classes/fact_diff.py @@ -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) diff --git a/plugins/modules/cli_parse.py b/plugins/modules/cli_parse.py index 89d7f67..fc4d801 100644 --- a/plugins/modules/cli_parse.py +++ b/plugins/modules/cli_parse.py @@ -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: """ diff --git a/plugins/modules/fact_diff.py b/plugins/modules/fact_diff.py index b810772..2d71ceb 100644 --- a/plugins/modules/fact_diff.py +++ b/plugins/modules/fact_diff.py @@ -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 """ diff --git a/plugins/modules/update_fact.py b/plugins/modules/update_fact.py index fd1214e..649ea66 100644 --- a/plugins/modules/update_fact.py +++ b/plugins/modules/update_fact.py @@ -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: [] diff --git a/plugins/modules/validate.py b/plugins/modules/validate.py index 8c676f4..7ca1ed1 100644 --- a/plugins/modules/validate.py +++ b/plugins/modules/validate.py @@ -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 """ diff --git a/plugins/test/validate.py b/plugins/test/validate.py index 5e4c210..0478037 100644 --- a/plugins/test/validate.py +++ b/plugins/test/validate.py @@ -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(..). + B(..). 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: diff --git a/plugins/validate/jsonschema.py b/plugins/validate/jsonschema.py index e1b24eb..3104f30 100644 --- a/plugins/validate/jsonschema.py +++ b/plugins/validate/jsonschema.py @@ -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 diff --git a/tests/integration/targets/cli_parse/tasks/main.yaml b/tests/integration/targets/cli_parse/tasks/main.yaml index e693c85..422d541 100644 --- a/tests/integration/targets/cli_parse/tasks/main.yaml +++ b/tests/integration/targets/cli_parse/tasks/main.yaml @@ -1,6 +1,6 @@ --- - name: Set a short name - set_fact: + ansible.builtin.set_fact: os: "{{ ansible_distribution|d }}" - include_tasks: argspec.yaml diff --git a/tests/integration/targets/cli_parse/tasks/nxos_json.yaml b/tests/integration/targets/cli_parse/tasks/nxos_json.yaml index e5de08f..2bbefb4 100644 --- a/tests/integration/targets/cli_parse/tasks/nxos_json.yaml +++ b/tests/integration/targets/cli_parse/tasks/nxos_json.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 diff --git a/tests/integration/targets/cli_parse/tasks/nxos_textfsm.yaml b/tests/integration/targets/cli_parse/tasks/nxos_textfsm.yaml index 880c313..208ab98 100644 --- a/tests/integration/targets/cli_parse/tasks/nxos_textfsm.yaml +++ b/tests/integration/targets/cli_parse/tasks/nxos_textfsm.yaml @@ -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" diff --git a/tests/integration/targets/cli_parse/tasks/nxos_ttp.yaml b/tests/integration/targets/cli_parse/tasks/nxos_ttp.yaml index 34a2f3d..6a75475 100644 --- a/tests/integration/targets/cli_parse/tasks/nxos_ttp.yaml +++ b/tests/integration/targets/cli_parse/tasks/nxos_ttp.yaml @@ -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" diff --git a/tests/integration/targets/cli_parse/tasks/nxos_xml.yaml b/tests/integration/targets/cli_parse/tasks/nxos_xml.yaml index 77dce9d..edccf85 100644 --- a/tests/integration/targets/cli_parse/tasks/nxos_xml.yaml +++ b/tests/integration/targets/cli_parse/tasks/nxos_xml.yaml @@ -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 diff --git a/tests/integration/targets/fact_diff/tasks/include/examples.yaml b/tests/integration/targets/fact_diff/tasks/include/examples.yaml index 2dc7938..a74a807 100644 --- a/tests/integration/targets/fact_diff/tasks/include/examples.yaml +++ b/tests/integration/targets/fact_diff/tasks/include/examples.yaml @@ -1,5 +1,5 @@ --- -- set_fact: +- ansible.builtin.set_fact: before: a: b: diff --git a/tests/integration/targets/get_path/tasks/include/argspec.yaml b/tests/integration/targets/get_path/tasks/include/argspec.yaml index 8aec6c5..56728e0 100644 --- a/tests/integration/targets/get_path/tasks/include/argspec.yaml +++ b/tests/integration/targets/get_path/tasks/include/argspec.yaml @@ -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 diff --git a/tests/integration/targets/get_path/tasks/include/simple.yaml b/tests/integration/targets/get_path/tasks/include/simple.yaml index d69bbbc..769ff16 100644 --- a/tests/integration/targets/get_path/tasks/include/simple.yaml +++ b/tests/integration/targets/get_path/tasks/include/simple.yaml @@ -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: diff --git a/tests/integration/targets/index_of/tasks/include/argspec.yaml b/tests/integration/targets/index_of/tasks/include/argspec.yaml index 9d72369..7306803 100644 --- a/tests/integration/targets/index_of/tasks/include/argspec.yaml +++ b/tests/integration/targets/index_of/tasks/include/argspec.yaml @@ -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 diff --git a/tests/integration/targets/index_of/tasks/include/examples_filter.yaml b/tests/integration/targets/index_of/tasks/include/examples_filter.yaml index 9c7a5f1..dac52eb 100644 --- a/tests/integration/targets/index_of/tasks/include/examples_filter.yaml +++ b/tests/integration/targets/index_of/tasks/include/examples_filter.yaml @@ -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: diff --git a/tests/integration/targets/index_of/tasks/include/examples_lookup.yaml b/tests/integration/targets/index_of/tasks/include/examples_lookup.yaml index 548aa54..f30cd30 100644 --- a/tests/integration/targets/index_of/tasks/include/examples_lookup.yaml +++ b/tests/integration/targets/index_of/tasks/include/examples_lookup.yaml @@ -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: diff --git a/tests/integration/targets/index_of/tasks/include/simple.yaml b/tests/integration/targets/index_of/tasks/include/simple.yaml index f6a81ac..c49aa19 100644 --- a/tests/integration/targets/index_of/tasks/include/simple.yaml +++ b/tests/integration/targets/index_of/tasks/include/simple.yaml @@ -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: diff --git a/tests/integration/targets/to_paths/tasks/include/argspec.yaml b/tests/integration/targets/to_paths/tasks/include/argspec.yaml index 619ba44..cc703da 100644 --- a/tests/integration/targets/to_paths/tasks/include/argspec.yaml +++ b/tests/integration/targets/to_paths/tasks/include/argspec.yaml @@ -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 diff --git a/tests/integration/targets/to_paths/tasks/include/examples_filter.yaml b/tests/integration/targets/to_paths/tasks/include/examples_filter.yaml index f5911d0..f64fd9c 100644 --- a/tests/integration/targets/to_paths/tasks/include/examples_filter.yaml +++ b/tests/integration/targets/to_paths/tasks/include/examples_filter.yaml @@ -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] ****************************************** diff --git a/tests/integration/targets/to_paths/tasks/include/examples_lookup.yaml b/tests/integration/targets/to_paths/tasks/include/examples_lookup.yaml index adf27a4..e3033d2 100644 --- a/tests/integration/targets/to_paths/tasks/include/examples_lookup.yaml +++ b/tests/integration/targets/to_paths/tasks/include/examples_lookup.yaml @@ -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] ****************************************** diff --git a/tests/integration/targets/to_paths/tasks/include/simple.yaml b/tests/integration/targets/to_paths/tasks/include/simple.yaml index ef255f3..23970f2 100644 --- a/tests/integration/targets/to_paths/tasks/include/simple.yaml +++ b/tests/integration/targets/to_paths/tasks/include/simple.yaml @@ -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: diff --git a/tests/integration/targets/update_fact/tasks/main.yaml b/tests/integration/targets/update_fact/tasks/main.yaml index de0a876..6d5165d 100644 --- a/tests/integration/targets/update_fact/tasks/main.yaml +++ b/tests/integration/targets/update_fact/tasks/main.yaml @@ -1,6 +1,6 @@ --- - name: Set a fact - set_fact: + ansible.builtin.set_fact: a: b: c: diff --git a/tests/integration/targets/validate/tasks/include/filter.yaml b/tests/integration/targets/validate/tasks/include/filter.yaml index d6a2eb1..a6b636a 100644 --- a/tests/integration/targets/validate/tasks/include/filter.yaml +++ b/tests/integration/targets/validate/tasks/include/filter.yaml @@ -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: diff --git a/tests/integration/targets/validate/tasks/include/lookup.yaml b/tests/integration/targets/validate/tasks/include/lookup.yaml index 6e389a4..5f6893e 100644 --- a/tests/integration/targets/validate/tasks/include/lookup.yaml +++ b/tests/integration/targets/validate/tasks/include/lookup.yaml @@ -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: diff --git a/tests/integration/targets/validate/tasks/include/module.yaml b/tests/integration/targets/validate/tasks/include/module.yaml index 3ffdbb0..d0d3cc3 100644 --- a/tests/integration/targets/validate/tasks/include/module.yaml +++ b/tests/integration/targets/validate/tasks/include/module.yaml @@ -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 diff --git a/tests/integration/targets/validate/tasks/include/test.yaml b/tests/integration/targets/validate/tasks/include/test.yaml index 9826252..5f77b45 100644 --- a/tests/integration/targets/validate/tasks/include/test.yaml +++ b/tests/integration/targets/validate/tasks/include/test.yaml @@ -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: diff --git a/tests/unit/plugins/action/test_fact_diff.py b/tests/unit/plugins/action/test_fact_diff.py index 14080da..facd720 100644 --- a/tests/unit/plugins/action/test_fact_diff.py +++ b/tests/unit/plugins/action/test_fact_diff.py @@ -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) diff --git a/tests/unit/plugins/action/test_update_fact.py b/tests/unit/plugins/action/test_update_fact.py index 9d17c9f..f0c4451 100644 --- a/tests/unit/plugins/action/test_update_fact.py +++ b/tests/unit/plugins/action/test_update_fact.py @@ -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)