zypper module dependency (catch 22)

Updated to ansible 2.9 and ran into a (semi) circular dependency for suse.
The zypper package now requires a non-stock python module, which… means it cannot be installed via the zypper module.

Workaround is to use the command module to install via zypper, but this seems an odd choice. Shouldn’t this just warn rather then force the install?

What non-stock module is required that is causing issues? The ansible module seems to only require default python modules.

Maybe you could explain your situation it more detail?

Playbook is simple cleanup of unneeded packages. Task like (without loop)

  • name: remove unneeded package
    zypper:
    name: cups
    state: absent

After update to 2.9 this error is thrown:

failed: [internum.augsburg.edu] (item=xhost) => {“ansible_loop_var”: “item”, “changed”: false, “item”: “xhost”, “module_stderr”: "Traceback (most recent call last):\n File "", line 102, in \n File "", line 94, in _ansiballz_main\n File "
“, line 40, in invoke_module\n File "/usr/lib64/python2.7/runpy.py", line 192, in run_module\n fname, loader, pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in run_globals\n File "/tmp/ansible_zypper_payload_2pSpWr/ansible_zypper_payload.zip/ansible/modules/packaging/
os/zypper.py", line 195, in \nImportError: No module named xml\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}
2019-11-05 14:50:47,427 p=fortier u=11890 | ok: [herodotus.augsburg.edu] => (item=cups-libs-32bit)

There’s a fair amount of noise in this error message (loop and hosts) but as I’m reading it, the key issue is

ImportError: No module named xml

I then tried loading python-xml (the dependency is mentioned in the current docs) with this:

  • name: load required ansible python module
    zypper:
  • name: python-xml
  • state: present

And received the same error.

I sort of get what’s going on here, current version of zypper have rich xml support, which is easier/cleaner/more-accurate than parsing CLI output, but it seems to me a regression to not allow the older style (with a warning).

That is interesting. I’ve not seen a distro that separated out the xml module into its own package as that is part of the CPython standard library.

Perhaps you have some python-minimal installed instead of a full python?

Fwiw, our suse images we are using in CI do not suffer from this problem.

On another note, sometimes hosts may be lacking dependencies that are fundamental to Ansible functioning. Often the tasks to ensure the systems meet the requirements to be managed by ansible are called “bootstrap” tasks, and are typically just command/shell/script/raw tasks that can configure a system at a minimal level to get necessary deps installed. So it is not unheard of to have these types of tasks.