Roots Discourse

Cannot deploy after trellis update

Hi,

I’ve been having trouble getting my site back to normal after updating trellis. It seems like one thing leads to another…

Right now, I’m having trouble deploying changes to the site. When I run ./bin/deploy.sh staging mysitename.com I get an error (the error message changes depending on which version of ansible I have - I’ve tried 2.9, 2.10, 2. 5, 4. 3, 2.3, and a few others). The deployment doesn’t run at all. I’ve tried installing different versions of ansible using pip, as well as apt (one thing to note - running ansible --version with version greater than 2.7 returns the error below, even though pip installs successfully).

I can deploy my other sites, with old versions of trellis, without an issue.

Linux mint cinnamon 3.8.8
Wordpress 5.8

Thanks for reading!

Jill

PS Here’s a list of a errors received using various versions of ansible:

ansible 4.3

./bin/deploy.sh: line 45: ansible-playbook: command not found

ansible 2.10

./bin/deploy.sh: line 45: ansible-playbook: command not found

ansible 2.9

ERROR! Unexpected Exception, this is probably a bug: cannot import name AnsibleCollectionLoader
the full traceback was:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-playbook", line 92, in <module>
    mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
  File "/usr/local/lib/python2.7/dist-packages/ansible/cli/__init__.py", line 22, in <module>
    from ansible.inventory.manager import InventoryManager
  File "/usr/local/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 38, in <module>
    from ansible.plugins.loader import inventory_loader
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/loader.py", line 25, in <module>
    from ansible.utils.collection_loader import AnsibleCollectionLoader, AnsibleFlatMapLoader, AnsibleCollectionRef
ImportError: cannot import name AnsibleCollectionLoader

ansible 2.4

ERROR! Unexpected Exception, this is probably a bug: cannot import name context

And this is the error I’m seeing after running ansible --version when using ansible versions 2.8 or greater:

ERROR! Unexpected Exception, this is probably a bug: cannot import name AnsibleCollectionLoader
the full traceback was:

Traceback (most recent call last):
  File "/usr/local/bin/ansible", line 90, in <module>
    mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
  File "/usr/local/lib/python2.7/dist-packages/ansible/cli/__init__.py", line 22, in <module>
    from ansible.inventory.manager import InventoryManager
  File "/usr/local/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 38, in <module>
    from ansible.plugins.loader import inventory_loader
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/loader.py", line 27, in <module>
    from ansible.utils.collection_loader import AnsibleCollectionLoader, AnsibleFlatMapLoader, is_collection_ref
ImportError: cannot import name AnsibleCollectionLoader

Update: I fixed the issue where my computer isn’t recognizing ansible (for ansible version <= 2.7). The primary problem persists.

Do you still get ansible-related errors or errors concerning the provisioning of the target system?

I get the same errors as mentioned in my original post

What kind of system is this? Linux, Ubuntu/Debian; OS X; WSL 1/2?
Are you using pip as root or as normal user?
Does the pip installation of ansible run through without errors?
What python version are you using?
Sometimes ansible is installed on different python versions.

Thanks for your help. I’m running Linux mint cinnamon 3.8.8, using pip as super user, pip runs without errors,
Python 2.7, pip 19.2.3.

Would a simple ansible --version work?

It works until ansible version 2.8 (good question - I edited my comment above to reflect that).

What does which ansible command say for a non-working ansible version, and what path does it print for a working one?

How are you installing these ansible versions using pip - what is the exact command and what is the output?

which ansible returns /usr/local/bin/ansible for ansible version 2.8 (for which ansible --version would return an error).

I just change the ansible version using sudo pip install ansible==X.X

Here’s the full output of updating ansible 2.7 to 2.8:

jill@jill-Inspiron-7373:~/Sites/sitename/trellis$ sudo pip install ansible==2.8

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/home/jill/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/jill/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ansible==2.8
  Downloading https://files.pythonhosted.org/packages/17/c9/d379b76ecaa42f4ee08b01c365e9ed1be0b302ff8a26eef120d481b144fa/ansible-2.8.0.tar.gz (14.3MB)
     |████████████████████████████████| 14.3MB 156kB/s 
Requirement already satisfied: jinja2 in /home/jill/.local/lib/python2.7/site-packages (from ansible==2.8) (2.10)
Requirement already satisfied: PyYAML in /home/jill/.local/lib/python2.7/site-packages (from ansible==2.8) (5.1)
Requirement already satisfied: cryptography in /home/jill/.local/lib/python2.7/site-packages (from ansible==2.8) (2.6.1)
Requirement already satisfied: MarkupSafe>=0.23 in /home/jill/.local/lib/python2.7/site-packages (from jinja2->ansible==2.8) (1.1.1)
Requirement already satisfied: asn1crypto>=0.21.0 in /home/jill/.local/lib/python2.7/site-packages (from cryptography->ansible==2.8) (0.24.0)
Requirement already satisfied: enum34; python_version < "3" in /home/jill/.local/lib/python2.7/site-packages (from cryptography->ansible==2.8) (1.1.6)
Requirement already satisfied: ipaddress; python_version < "3" in /home/jill/.local/lib/python2.7/site-packages (from cryptography->ansible==2.8) (1.0.22)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /home/jill/.local/lib/python2.7/site-packages (from cryptography->ansible==2.8) (1.12.2)
Requirement already satisfied: six>=1.4.1 in /home/jill/.local/lib/python2.7/site-packages (from cryptography->ansible==2.8) (1.12.0)
Requirement already satisfied: pycparser in /home/jill/.local/lib/python2.7/site-packages (from cffi!=1.11.3,>=1.8->cryptography->ansible==2.8) (2.19)
Installing collected packages: ansible
  Found existing installation: ansible 2.7.0
    Uninstalling ansible-2.7.0:
      Successfully uninstalled ansible-2.7.0
  Running setup.py install for ansible ... done
Successfully installed ansible-2.8.0

You could first uninstall all ansible packages on that workstation, including one potentially being installed by a package manager (e.g. apt) instead. In the end no ansible command should be found anymore.
For being sure that everything can be re-installed cleanly, you can use the pip-autoremove tool.

Then re-install an ansible version that hadn’t worked before and hopefully it is cleanly installed.

1 Like

That fixed my issue. Thank you for your help!

This topic was automatically closed after 42 days. New replies are no longer allowed.