Hi, > I try to handle docker containers via Ansible and am getting this > error: > msg: 'Failed to import the required Python library (Docker SDK > for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on > vm-51150-0191''s Python /usr/libexec/platform-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 > ''docker''' > > I assume that means the target host needs to have a python docker > module/library/package (sorry I am not 100% aware what the correcet > term is here).
yes, that is correct. Generally the requirements for a module are needed in the environment the module is executed. Most modules run on the target host. (If you don't use `delegate_to: localhost` or something like that, or have one of the rare modules which are actually implemented as action plugins and thus run on the controller.) > I read pip install docker to be the common solution, but am advised > in my workplace to go around pip if possible (I miss the knowledge to > discuss the reasons for this though). > > So, is the alternative to install it manually (I found these > instructions)? The best alternative is usually to install it from system packages. For example, on Ubuntu and Debian, there's the python3-docker system package you can install. For other OSes similar packages might exist. Depending on which modules/plugins you need, you might also be interested in the current 3.0.0-a1 prerelease of community.docker, where some of the modules were rewritten to work with only requests (and some more dependencies, depending on your Python version, and how exactly you connect to the Docker daemon; see https://github.com/ansible-collections/community.docker#external-requirements for more details). For a list of plugins/modules that were adjusted so far see https://github.com/ansible-collections/community.docker/issues/364#issuecomment-1172957628 Please note that these new versions haven't yet been extensively tested, so there might be bugs. Best regards, Felix -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20220707135928.39745051%40rovaniemi.
