Hi there, if i execute trellis deploy production example.com i get this error:
Running command => ansible-playbook deploy.yml -e env=production site=***.ch
Traceback (most recent call last):
File "/Users/user/project/trellis/.trellis/virtualenv/bin/ansible-playbook", line 34, in <module>
from ansible import context
ModuleNotFoundError: No module named 'ansible'
What’s the problem here?
Maybe this has something to do with this issue: when i’m working on this trellis project i always had to return node to 10.20.1, so i switched to that version with n version manager. I noticed a permission denied message due during the process and it looks like this:
If there are still issues with ansible, uninstall all ansible python packages (e.g. using pip) and system packages (e…g using apt) and re-install it again.
I don’t get it.
Checking my Ansible Version with ansible --version and get this: ansible 2.9.10
But bellow the version number i get more information and one line is: python version = 2.7.16 (default, Mar 25 2021, 03:11:28) [GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc-
So i’m wondering why is there python version 2.7.16?
So checking python version with python -V: Python 3.9.7
But when i do pip install ansible==2.9.10 i get a warning message with: DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Ok, i executed ansible-playbook deploy.yml -e "site=example.ch env=production" and it worked.
Deploy was successfull, but i had 2 warnings:
[WARNING]: Skipping plugin (/Users/user/Library/Python/2.7/lib/python/site-packages/ansible/plugins/connection/accelerate.py) as it seems to be invalid: cannot import name key_for_hostname
[DEPRECATION WARNING]: Distribution Ubuntu 20.04 on host *** should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
So what should i do?
Anyway, trellis deploy production example.ch still doesn’t work.
You probably used python 2 pip, not python 3 (python3) pip. Try pip3 command instead. You can also uninstall the python 2 pip-installed ansible to be sure that python 3 pip-installed ansible is used.