diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0ffad9e..081a2df 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,7 @@ jobs: all_green: if: ${{ always() }} needs: + - ansible-lint - changelog - integration - sanity @@ -39,7 +40,7 @@ jobs: set([ '${{ needs.ansible-lint.result }}', '${{ needs.changelog.result }}', + '${{ needs.integration.result }}', '${{ needs.sanity.result }}', - '${{ needs.unit-galaxy.result }}', - '${{ needs.unit-source.result }}' + '${{ needs.unit-galaxy.result }}' ])" diff --git a/README.md b/README.md index c8d7e0b..70de6c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ansible Utilities Collection [![Codecov](https://codecov.io/gh/ansible-collections/ansible.utils/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/ansible.utils) -[![CI](https://github.com/ansible-collections/ansible.utils/actions/workflows/test.yml/badge.svg?branch=main&event=schedule)](https://github.com/ansible-collections/ansible.utils/actions/workflows/test.yml) +[![CI](https://github.com/ansible-collections/ansible.utils/actions/workflows/tests.yml/badge.svg?branch=main&event=schedule)](https://github.com/ansible-collections/ansible.utils/actions/workflows/tests.yml) The Ansible ``ansible.utils`` collection includes a variety of plugins that aid in the management, manipulation and visibility of data for the Ansible playbook developer. diff --git a/plugins/sub_plugins/validate/config.py b/plugins/sub_plugins/validate/config.py index f3e6787..eff3044 100644 --- a/plugins/sub_plugins/validate/config.py +++ b/plugins/sub_plugins/validate/config.py @@ -48,6 +48,8 @@ EXAMPLES = r""" import re +from io import StringIO + from ansible.errors import AnsibleError from ansible.module_utils._text import to_text from ansible.module_utils.six import string_types @@ -87,7 +89,7 @@ class Validate(ValidateBase): try: if isinstance(self._criteria, string_types): - self._criteria = yaml.load(str(self._criteria), Loader=SafeLoader) + self._criteria = yaml.load(StringIO(self._criteria), Loader=SafeLoader) except yaml.parser.ParserError as exc: msg = ( "'criteria' option value is invalid, value should be valid YAML." @@ -105,7 +107,9 @@ class Validate(ValidateBase): issues.append('Criteria {item} missing "action" key'.format(item=item)) elif item["action"] not in ("warn", "fail"): issues.append( - 'Action in criteria {item} is not one of "warn" or "fail"'.format(item=item), + 'Action in criteria {item} is not one of "warn" or "fail"'.format( + item=item, + ), ) if "rule" not in item: issues.append('Criteria {item} missing "rule" key'.format(item=item)) @@ -159,7 +163,9 @@ class Validate(ValidateBase): warnings.append(format_message(match, line_number, criteria)) if criteria["action"] == "fail": errors.append({"message": criteria["name"], "found": line}) - error_messages.append(format_message(match, line_number, criteria)) + error_messages.append( + format_message(match, line_number, criteria), + ) if errors: if "errors" not in self._result: diff --git a/tests/integration/targets/utils_cli_parse/tasks/nxos_ttp.yaml b/tests/integration/targets/utils_cli_parse/tasks/nxos_ttp.yaml index f883b74..f6a04ad 100644 --- a/tests/integration/targets/utils_cli_parse/tasks/nxos_ttp.yaml +++ b/tests/integration/targets/utils_cli_parse/tasks/nxos_ttp.yaml @@ -16,7 +16,7 @@ ansible.builtin.assert: that: - "{{ POpqMQoJWTiDpEW is defined }}" - - "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}" + - nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length - "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}" - name: "Pass text and custom variable {{ parser }}" @@ -49,6 +49,6 @@ - name: "Confirm modified results {{ parser }}" ansible.builtin.assert: - that: "{{ item }}" + that: item with_items: - "{{ (nxos_ttp_results['parsed'][0] | from_yaml)[0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"