Closed SamYuan1990 closed 3 years ago
Did you install the Docker SDK for Python for the same Python that Ansible uses on your target? I.e. for the Python in /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python on 192.168.1.6?
@SamYuan1990 can you please answer this question?
Did you install the Docker SDK for Python for the same Python that Ansible uses on your target? I.e. for the Python in /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python on 192.168.1.6?
sorry for reply late, yes I installed docker sdk for python as hint, and retried many times.
but I am not sure if the problem is related to python or $PATH
I tried to print $PATH
from ansible and by ssh in console, and the result for $PATH
is different.
seems that echo $PATH
missing some path for libs.
I don't think $PATH is related to this. You seem to have installed Ansible with Python 3.9.1, but Ansible uses Python 2.7 on your machine. So you need to either install Docker SDK for Python for the Python 2.7 on your machine, or you need to tell Ansible to use Python 3.9.1 and not Python 2.7. For the latter, you can use the ansible_python_interpreter
inventory (or local) variable.
Example:
- hosts: localhost
vars:
ansible_python_interpreter: /path/to/python3.9
tasks:
...
but for distributes considering, is it good idea to had code as:
vars:
ansible_python_interpreter: /path/to/python3.9
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
is only for local mac right? if I use mac for dev, and others use for linux?
It's definitely not. But it shows that in this case, you simply installed the Docker SDK for Python for the wrong Python version on your local machine. If you install it for the correct one, you don't need this hack.
In any case, this is not a bug in the collection, but a usage problem. These can be discussed in the ansible-project mailing list or in #ansible in IRC. I'll close this issue because of that.
SUMMARY
Seems this module fails on Mac
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
start a busybox
ACTUAL RESULTS