Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with backports.ssl-match-hostname for Python docker module #25

Closed
qmacro opened this issue Feb 8, 2020 · 2 comments
Closed

Issue with backports.ssl-match-hostname for Python docker module #25

qmacro opened this issue Feb 8, 2020 · 2 comments

Comments

@qmacro
Copy link

qmacro commented Feb 8, 2020

This might be too specific an error but it happened to me. In Ch.3 section "docker_image module" we start with the playbook for building the Docker image, using the docker_image module.

Running the playbook at this point (before moving on to the next section) resulted in an error for me:

"msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on penguin's Python /usr/bin/python. 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` or `pip install docker-py` (Python 2.6). The error was: No module named ssl_match_hostname"    

I finally solved this with a slightly extreme install of the backports.ssl-match-hostname module as described in this SO solution: https://stackoverflow.com/a/51071841/384366

It might be only me that experienced this, but flagging this just in case it's others and you want to put a note in this section.

@geerlingguy
Copy link
Owner

I'll have to do a little more testing on this, to make sure it accounts for the case of someone new to Ansible/this example. If you ran into it, chances are someone else will to... one of the things I made sure to do with Ansible for DevOps at one point was take a fresh new machine, and run through the first few chapters to make sure I wasn't missing the install or configuration of something critical.

@geerlingguy
Copy link
Owner

geerlingguy commented Mar 11, 2020

@qmacro - Thanks again for opening this issue (as I said, if you got this error, chances are someone else did/will too...).

It looks like there are a few possible causes of this problem—and if you look through the main issue relating to this in the docker-py issue queue (docker/docker-py#1502), you'll see there are also a hundred solutions!

It seems like the most important things to try are:

  1. Make sure you're installing docker and not docker-py (pip3 install docker).
  2. Make sure the Ansible playbook is using the same python interpreter where you just installed the docker library, e.g. if you used pip3, see if setting export ANSIBLE_PYTHON_INTERPRETER=$(which python3) gets you a better result.

It seems like 90% of the people reporting issues had problems with their Ansible playbook or other Python projects picking up either a broken installation of the docker library, or just using the wrong Python interpreter altogether (e.g. not using a venv correctly, or using system Python instead of a managed installation...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants