mitogen
mitogen copied to clipboard
What do "present in the Mitogen importer blacklist" errors mean?
ubuntu 20.04 ansible 2.9.6 python 3.8.2 mitogen beta 0.2.10 2020-05-16 (also tried 0.2.9)
I often get similar error to the one below. They generally say something like
The error was: 'FOO' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused.
In this particular case, I'm checking something on localhost:
- docker_swarm_info:
ignore_errors: yes
register: result
Error:
fatal: [localhost]: FAILED! => {"can_talk_to_docker": false, "changed": false, "docker_swarm_active": false, "docker_swarm_manager": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on lonix1's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via
pip install docker
orpip install docker-py
(Python 2.6). The error was: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused."}
It works when mitogen isn't enabled.
This part is the most important: on lonix1's Python /usr/bin/python3
.
Mitogen works by streaming package data to its clients, so if the package doesn't exist on your host machine (the "master") then it doesn't make sense for the target node to request it from the master because it doesn't exist there.
Mitogen is designed to require minimal installation of packages to get stuff to work on target hosts :) Please try installing docker
on your host via /usr/bin/python3 -m pip install docker
and rerunning. This is the python that Mitogen detected it should use which might be different than what Ansible defaults to (although it shouldn't; I call the same code from Ansible that it uses to detect python versions 🤔 ). At first guess, it might be due to a symlink pointing to a different Python.
If that doesn't work I can take a closer look! It'll also help if you can reproduce the issue with a minimal Dockerfile in that case.
Thanks.
I'm not a python dev so it'll take a while to dig into your recommendations.
In the meantime, I looked into the symlink theory. This is what I found:
Master's ansible.cfg
:
[defaults]
interpreter_python = /usr/bin/python3
strategy_plugins = ~/.mitogen/ansible_mitogen/plugins/strategy
strategy = mitogen_linear
Master:
$ which python; which python2; which python3
/usr/bin/python
/usr/bin/python2
/usr/bin/python3
$ python --version; python2 --version; python3 --version
Python 2.7.18rc1
Python 2.7.18rc1
Python 3.8.2
Remote:
$ which python; which python2; which python3
/usr/bin/python
/usr/bin/python2
/usr/bin/python3
$ python --version; python2 --version; python3 --version
Python 2.7.17
Python 2.7.17
Python 3.6.9
Looks ok?
Sorry for the late response; I thought I responded to this already :(
The symlink stuff looks ok. Does this show docker
on your host?
$ /usr/bin/python3 -m pip freeze | grep docker
@s1113950 I have same problem. My playbook for reproducing:
- hosts: all
become: true
tasks:
- name: step1
ansible.builtin.pip:
name: docker
executable: pip3
- name: step2
community.docker.docker_host_info:
Error:
fatal: [myhost.com]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/bin/python3.6"}, "can_talk_to_docker": false, "changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on myhost.com's Python /bin/python3.6. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via
pip install docker
(Python >= 3.6) orpip install docker==4.4.4
(Python 2.7) orpip install docker-py
(Python 2.6). The error was: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused."}
Important moment: playbook is restarted without errors.
But, I found workaround. It need to reset connection between step 1 and step2. Like this:
- hosts: all
become: true
tasks:
- name: step1
ansible.builtin.pip:
name: docker
executable: /bin/pip3.6
- name: reset ssh connection
ansible.builtin.meta: reset_connection
- name: step2
community.docker.docker_host_info:
Info about my system: OS: Oracle Linux Server 8.4 Ansible: 2.10.11 mitogen: 0.3.0-rc1
Python:
[[email protected] ~]# /bin/python3.6 --version
Python 3.6.8
Docker package:
[[email protected] ~]# /bin/pip3.6 list | grep docker
docker (5.0.0)
Sorry for the late response; I thought I responded to this already :( The symlink stuff looks ok. Does this show
docker
on your host?$ /usr/bin/python3 -m pip freeze | grep docker
Docker is installed
$ /usr/bin/python3 -m pip freeze | grep docker
docker==5.0.3
Still mitogen fails with
Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on ec3fa6e91296''s Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` (Python >= 3.6) or `pip install docker==4.4.4` (Python 2.7) or `pip install docker-py` (Python 2.6). The error was: ''docker'' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused.'
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused.
Obviously imports just fine in the REPL.
ansible_facts:
discovered_interpreter_python: /usr/bin/python3
FWIW I was also seeing a similar error when running a task like:
community.general.docker_container:
name: sphinx
image: macbre/sphinxsearch:3.4.1
state: started
restart_policy: unless-stopped
container_default_behavior: no_defaults
user: "{{ getent_passwd['sphinx'].1 }}:{{ getent_passwd['sphinx'].2 }}"
resulting in:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused. fatal: [development-server1-1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on development-server1-1's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via
pip install docker
(Python >= 3.6) orpip install docker==4.4.4
(Python 2.7) orpip install docker-py
(Python 2.6). The error was: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused."}
However! If I change my playbook strategy back to linear
to bypass mitogen entirely, it still fails:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'docker' fatal: [development-server1-1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on development-server1-1's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via
pip install docker
(Python >= 3.6) orpip install docker==4.4.4
(Python 2.7) orpip install docker-py
(Python 2.6). The error was: No module named 'docker'"}
So (at least in my case) the "Mitogen importer blacklist" error message was misleading (my actual problem was that I'd run pip3 install docker
as a user account, then tried to run community.general.docker_container as root).
in my case i get a similar error but using the linear strategy makes the problem go away ...
any hint why this is not working ?
Sorry for the late response; I thought I responded to this already :( The symlink stuff looks ok. Does this show
docker
on your host?$ /usr/bin/python3 -m pip freeze | grep docker
Docker is installed
$ /usr/bin/python3 -m pip freeze | grep docker docker==5.0.3
Still mitogen fails with
Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on ec3fa6e91296''s Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` (Python >= 3.6) or `pip install docker==4.4.4` (Python 2.7) or `pip install docker-py` (Python 2.6). The error was: ''docker'' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused.' An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: 'docker' is present in the Mitogen importer blacklist, therefore this context will not attempt to request it from the master, as the request will always be refused.
Obviously imports just fine in the REPL.
ansible_facts: discovered_interpreter_python: /usr/bin/python3
How did you end up solving this problem?