Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-ansible-compat for openSUSE:Factory checked in at 2023-05-31 21:55:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-ansible-compat (Old) and /work/SRC/openSUSE:Factory/.python-ansible-compat.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-ansible-compat" Wed May 31 21:55:00 2023 rev:16 rq:1089988 version:4.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-ansible-compat/python-ansible-compat.changes 2023-05-23 14:54:30.962473419 +0200 +++ /work/SRC/openSUSE:Factory/.python-ansible-compat.new.1533/python-ansible-compat.changes 2023-05-31 21:55:04.481210102 +0200 @@ -1,0 +2,17 @@ +Tue May 30 11:44:08 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- update to 4.1.1: + * Bugfixes + - Disable Ansible debug mode for sub-commands (#284) @ssbarnea + - Log retry attempt only when doing retries (#283) @ssbarnea + +------------------------------------------------------------------- +Wed May 24 14:05:34 UTC 2023 - Johannes Kastl <ka...@b1-systems.de> + +- update to 4.1.0: + * Minor Changes + - Enable access to available plugins (#277) @ssbarnea + * Bugfixes + - Avoid creating ~/.ansible/collections (#280) @ssbarnea + +------------------------------------------------------------------- Old: ---- ansible-compat-4.0.5.tar.gz New: ---- ansible-compat-4.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ansible-compat.spec ++++++ --- /var/tmp/diff_new_pack.BVqtWY/_old 2023-05-31 21:55:05.005213199 +0200 +++ /var/tmp/diff_new_pack.BVqtWY/_new 2023-05-31 21:55:05.009213222 +0200 @@ -24,7 +24,7 @@ %endif Name: python-ansible-compat -Version: 4.0.5 +Version: 4.1.1 Release: 0 Summary: Compatibility shim for Ansible 2.9 and newer License: MIT ++++++ ansible-compat-4.0.5.tar.gz -> ansible-compat-4.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/.gitignore new/ansible-compat-4.1.1/.gitignore --- old/ansible-compat-4.0.5/.gitignore 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/.gitignore 2023-05-30 13:48:54.000000000 +0200 @@ -128,3 +128,4 @@ .pyre/ .test-results *.lcov +ansible_collections diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/.vscode/settings.json new/ansible-compat-4.1.1/.vscode/settings.json --- old/ansible-compat-4.0.5/.vscode/settings.json 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/.vscode/settings.json 2023-05-30 13:48:54.000000000 +0200 @@ -5,9 +5,8 @@ "[python]": { "editor.codeActionsOnSave": { "source.fixAll": true, - "source.fixAll.ruff": true, - "source.organizeImports": false, - "source.organizeImports.ruff": true + "source.fixAll.ruff": false, + "source.organizeImports": false } }, "editor.formatOnSave": true, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/PKG-INFO new/ansible-compat-4.1.1/PKG-INFO --- old/ansible-compat-4.0.5/PKG-INFO 2023-05-21 14:32:44.496278500 +0200 +++ new/ansible-compat-4.1.1/PKG-INFO 2023-05-30 13:49:11.425784300 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ansible-compat -Version: 4.0.5 +Version: 4.1.1 Summary: Ansible compatibility goodies Author-email: Sorin Sbarnea <ssbar...@redhat.com> Maintainer-email: Sorin Sbarnea <ssbar...@redhat.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/ansible.cfg new/ansible-compat-4.1.1/ansible.cfg --- old/ansible-compat-4.0.5/ansible.cfg 1970-01-01 01:00:00.000000000 +0100 +++ new/ansible-compat-4.1.1/ansible.cfg 2023-05-30 13:48:54.000000000 +0200 @@ -0,0 +1,3 @@ +[defaults] +# isolate testing of ansible-compat from user local setup +collections_path = . diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/pyproject.toml new/ansible-compat-4.1.1/pyproject.toml --- old/ansible-compat-4.0.5/pyproject.toml 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/pyproject.toml 2023-05-30 13:48:54.000000000 +0200 @@ -112,6 +112,7 @@ "import-error", # already covered by ruff which is faster "too-many-arguments", # PLR0913 + "raise-missing-from", # Temporary disable duplicate detection we remove old code from prerun "duplicate-code", ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/src/ansible_compat/runtime.py new/ansible-compat-4.1.1/src/ansible_compat/runtime.py --- old/ansible-compat-4.0.5/src/ansible_compat/runtime.py 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/src/ansible_compat/runtime.py 2023-05-30 13:48:54.000000000 +0200 @@ -10,9 +10,9 @@ import tempfile import warnings from collections import OrderedDict -from dataclasses import dataclass +from dataclasses import dataclass, field from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Optional, Union +from typing import TYPE_CHECKING, Any, Callable, Optional, Union, no_type_check import subprocess_tee from packaging.version import Version @@ -20,6 +20,7 @@ from ansible_compat.config import ( AnsibleConfig, ansible_collections_path, + ansible_version, parse_ansible_version, ) from ansible_compat.constants import ( @@ -73,6 +74,71 @@ super().__init__(version) +@dataclass +class Plugins: # pylint: disable=too-many-instance-attributes + """Dataclass to access installed Ansible plugins, uses ansible-doc to retrieve them.""" + + runtime: "Runtime" + become: dict[str, str] = field(init=False) + cache: dict[str, str] = field(init=False) + callback: dict[str, str] = field(init=False) + cliconf: dict[str, str] = field(init=False) + connection: dict[str, str] = field(init=False) + httpapi: dict[str, str] = field(init=False) + inventory: dict[str, str] = field(init=False) + lookup: dict[str, str] = field(init=False) + netconf: dict[str, str] = field(init=False) + shell: dict[str, str] = field(init=False) + vars: dict[str, str] = field(init=False) # noqa: A003 + module: dict[str, str] = field(init=False) + strategy: dict[str, str] = field(init=False) + test: dict[str, str] = field(init=False) + filter: dict[str, str] = field(init=False) # noqa: A003 + role: dict[str, str] = field(init=False) + keyword: dict[str, str] = field(init=False) + + @no_type_check + def __getattribute__(self, attr: str): # noqa: ANN204 + """Get attribute.""" + if attr in { + "become", + "cache", + "callback", + "cliconf", + "connection", + "httpapi", + "inventory", + "lookup", + "netconf", + "shell", + "vars", + "module", + "strategy", + "test", + "filter", + "role", + "keyword", + }: + try: + result = super().__getattribute__(attr) + except AttributeError as exc: + if ansible_version() < Version("2.14") and attr in {"filter", "test"}: + msg = "Ansible version below 2.14 does not support retrieving filter and test plugins." + raise RuntimeError(msg) from exc + proc = self.runtime.run( + ["ansible-doc", "--json", "-l", "-t", attr], + ) + data = json.loads(proc.stdout) + if not isinstance(data, dict): # pragma: no cover + msg = "Unexpected output from ansible-doc" + raise AnsibleCompatError(msg) from exc + result = data + else: + result = super().__getattribute__(attr) + + return result + + # pylint: disable=too-many-instance-attributes class Runtime: """Ansible Runtime manager.""" @@ -83,6 +149,7 @@ # Used to track if we have already initialized the Ansible runtime as attempts # to do it multiple tilmes will cause runtime warnings from within ansible-core initialized: bool = False + plugins: Plugins def __init__( self, @@ -119,6 +186,7 @@ self.isolated = isolated self.max_retries = max_retries self.environ = environ or os.environ.copy() + self.plugins = Plugins(runtime=self) # Reduce noise from paramiko, unless user already defined PYTHONWARNINGS # paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated # https://github.com/paramiko/paramiko/issues/2038 @@ -164,9 +232,6 @@ self.collections = OrderedDict() no_collections_msg = "None of the provided paths were usable" - # Workaround for https://github.com/ansible/ansible/issues/73127 - Path("~/.ansible/collections").expanduser().mkdir(exist_ok=True, parents=True) - proc = self.run(["ansible-galaxy", "collection", "list", "--format=json"]) if proc.returncode == RC_ANSIBLE_OPTIONS_ERROR and ( no_collections_msg in proc.stdout or no_collections_msg in proc.stderr @@ -262,6 +327,10 @@ run_func: Callable[..., CompletedProcess] = subprocess_tee.run else: run_func = subprocess.run + env = self.environ if env is None else env.copy() + # Presence of ansible debug variable or config option will prevent us + # from parsing its JSON output due to extra debug messages on stdout. + env["ANSIBLE_DEBUG"] = "0" for _ in range(self.max_retries + 1 if retry else 1): result = run_func( @@ -270,17 +339,18 @@ check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env or self.environ, + env=env, cwd=str(cwd) if cwd else None, ) if result.returncode == 0: break - _logger.debug("Environment: %s", env or self.environ) - _logger.warning( - "Retrying execution failure %s of: %s", - result.returncode, - " ".join(args), - ) + _logger.debug("Environment: %s", env) + if retry: + _logger.warning( + "Retrying execution failure %s of: %s", + result.returncode, + " ".join(args), + ) return result @property diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/src/ansible_compat.egg-info/PKG-INFO new/ansible-compat-4.1.1/src/ansible_compat.egg-info/PKG-INFO --- old/ansible-compat-4.0.5/src/ansible_compat.egg-info/PKG-INFO 2023-05-21 14:32:44.000000000 +0200 +++ new/ansible-compat-4.1.1/src/ansible_compat.egg-info/PKG-INFO 2023-05-30 13:49:11.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ansible-compat -Version: 4.0.5 +Version: 4.1.1 Summary: Ansible compatibility goodies Author-email: Sorin Sbarnea <ssbar...@redhat.com> Maintainer-email: Sorin Sbarnea <ssbar...@redhat.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/src/ansible_compat.egg-info/SOURCES.txt new/ansible-compat-4.1.1/src/ansible_compat.egg-info/SOURCES.txt --- old/ansible-compat-4.0.5/src/ansible_compat.egg-info/SOURCES.txt 2023-05-21 14:32:44.000000000 +0200 +++ new/ansible-compat-4.1.1/src/ansible_compat.egg-info/SOURCES.txt 2023-05-30 13:49:11.000000000 +0200 @@ -6,6 +6,7 @@ .yamllint LICENSE README.md +ansible.cfg codecov.yml mkdocs.yml pyproject.toml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/test/test_runtime.py new/ansible-compat-4.1.1/test/test_runtime.py --- old/ansible-compat-4.0.5/test/test_runtime.py 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/test/test_runtime.py 2023-05-30 13:48:54.000000000 +0200 @@ -15,6 +15,7 @@ from packaging.version import Version from pytest_mock import MockerFixture +from ansible_compat.config import ansible_version from ansible_compat.constants import INVALID_PREREQUISITES_RC from ansible_compat.errors import ( AnsibleCommandError, @@ -747,3 +748,44 @@ runtime.environ["FOO"] = "bar" result = runtime.run(["printenv", "FOO"]) assert result.stdout.rstrip() == "bar" + + +def test_runtime_plugins(runtime: Runtime) -> None: + """Tests ability to access detected plugins.""" + assert len(runtime.plugins.cliconf) == 0 + # ansible.netcommon.restconf might be in httpapi + assert isinstance(runtime.plugins.httpapi, dict) + # "ansible.netcommon.default" might be in runtime.plugins.netconf + assert isinstance(runtime.plugins.netconf, dict) + assert isinstance(runtime.plugins.role, dict) + assert "become" in runtime.plugins.keyword + + if ansible_version() < Version("2.14.0"): + assert "sudo" in runtime.plugins.become + assert "memory" in runtime.plugins.cache + assert "default" in runtime.plugins.callback + assert "local" in runtime.plugins.connection + assert "ini" in runtime.plugins.inventory + assert "env" in runtime.plugins.lookup + assert "sh" in runtime.plugins.shell + assert "host_group_vars" in runtime.plugins.vars + assert "file" in runtime.plugins.module + assert "free" in runtime.plugins.strategy + # ansible-doc below 2.14 does not support listing 'test' and 'filter' types: + with pytest.raises(RuntimeError): + assert "is_abs" in runtime.plugins.test + with pytest.raises(RuntimeError): + assert "bool" in runtime.plugins.filter + else: + assert "ansible.builtin.sudo" in runtime.plugins.become + assert "ansible.builtin.memory" in runtime.plugins.cache + assert "ansible.builtin.default" in runtime.plugins.callback + assert "ansible.builtin.local" in runtime.plugins.connection + assert "ansible.builtin.ini" in runtime.plugins.inventory + assert "ansible.builtin.env" in runtime.plugins.lookup + assert "ansible.builtin.sh" in runtime.plugins.shell + assert "ansible.builtin.host_group_vars" in runtime.plugins.vars + assert "ansible.builtin.file" in runtime.plugins.module + assert "ansible.builtin.free" in runtime.plugins.strategy + assert "ansible.builtin.is_abs" in runtime.plugins.test + assert "ansible.builtin.bool" in runtime.plugins.filter diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ansible-compat-4.0.5/tox.ini new/ansible-compat-4.1.1/tox.ini --- old/ansible-compat-4.0.5/tox.ini 2023-05-21 14:32:28.000000000 +0200 +++ new/ansible-compat-4.1.1/tox.ini 2023-05-30 13:48:54.000000000 +0200 @@ -8,7 +8,6 @@ py{39,310,311}{,-devel,-ansible212,-ansible213,-ansible214,-ansible215} isolated_build = true skip_missing_interpreters = True -skipsdist = true [testenv] description = @@ -28,7 +27,8 @@ devel: ansible-core @ git+https://github.com/ansible/ansible.git # GPLv3+ # avoid installing ansible-core on -devel envs: !devel: ansible-core - --editable .[test] +extras = + test commands = sh -c "ansible --version | head -n 1" @@ -68,12 +68,14 @@ PIP_DISABLE_PIP_VERSION_CHECK = 1 PIP_CONSTRAINT = {toxinidir}/requirements.txt PRE_COMMIT_COLOR = always - PYTEST_REQPASS = 81 + PYTEST_REQPASS = 82 FORCE_COLOR = 1 allowlist_externals = ansible git sh +# https://tox.wiki/en/latest/upgrading.html#editable-mode +package = editable [testenv:lint] description = Run all linters @@ -140,6 +142,5 @@ description = Build docs commands = mkdocs {posargs:build} --strict -deps = - --editable .[docs] +extras = docs passenv = *