Executing meta: end_play triggers AnsibleError.
I’m using an old Debian 11.11 host on which I installed years ago, Debian’s ansible package.
On this box, ansible 2.10.17 is installed along python 3.9.2.
As I couldn’t configure Trixie boxes with this setup, I installed in a dedicated Python venv, latest Ansible with uv pip install ansible.
After activating this venv, I’m seeing the (redacted) error bellow whenever meta: end_play is met ins any of my scripts.
`[ERROR]: Unexpected Exception, this is probably a bug: 0
Traceback (most recent call last):
File “/home/foobar/PythonEnvs/ansiblevenv/lib/python3.11/site-packages/ansible/cli/init.py”, line 660, in cli_executor
exit_code = cli.run()
^^^^^^^^^
File “/home/foobar/PythonEnvs/ansiblevenv/lib/python3.11/site-packages/ansible/cli/adhoc.py”, line 199, in run
result = self._tqm.run(play)
^^^^^^^^^^^^^^^^^^^
File “/home/foobar/PythonEnvs/ansiblevenv/lib/python3.11/site-packages/ansible/executor/task_queue_manager.py”, line 396, in run
raise AnsibleEndPlay(play_return)
ansible.executor.task_queue_manager.AnsibleEndPlay: 0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/home/foobar/PythonEnvs/ansiblevenv/lib/python3.11/site-packages/ansible/cli/init.py”, line 669, in cli_executor
raise AnsibleError(“Unexpected Exception, this is probably a bug.”) from ex
ansible.errors.AnsibleError: Unexpected Exception, this is probably a bug: 0`
You might accidentally be running the older system ansible binary. Check with these commands. They should both point to the newer version in your venv:
# Inside the virtual‑env (or after any “source” you use)
which ansible # full path to the binary
ansible --version # shows ansible‑core and collection versions
It seems latest ansible is correctly preferred but somehow mixed with the old one.
For instance, configured module search path and ansible collection location both refer to the .ansible directory used by the old ansible instance.
In this specific case, it seems more appropriate values should be configured module search path = ['/home/foobar/PythonEnvs/ansiblevenv/<something>/plugins/modules'] ansible collection location = /home/foobar/PythonEnvs/ansiblevenv/<something else>/collections
Looking at venv content, I’m not sure I can set <something> and <something else> to anything valid.
Is there a recommended way to set a config file within an Ansible venv ?
I can’t under-emphasize this enough. I’m not recommending it as a best- or even mediocre-practice. But it’s because of “stuff like this” that I treat the presence of any ansible.cfg file as an error. Any Ansible configuration I need to do I do through environment variables. Maybe it’s just a “me” thing, but having one source of truth for config is about my mental limit these days.
Also, make liberal use of ansible-config a habit, especially