Ansible upgrade breaks access to all other trellis deploys

I found a nice improvement to make which also kind of solves your use case: https://github.com/roots/trellis-cli/pull/73

  1. install virtualenv via pip install virtualenv
  2. virtualenv command should work globally now
  3. run export VIRTUALENV_PYTHON=<path to python2 binary>
  4. use trellis init

I’ll release this in a new version soon.

Thanks Scott! Sadly, still having one error.

Ok so I installed virtualenv and found where my python path was… I believe this should work: /usr/local/Cellar/python@2/2.7.15_1/bin

I ran export command and then trellis init and then trellis deploy and had the same issues. I then deleted the .trellis folder and ran trellis init again and trellis deploy… and same issues.

I then realized I still hadn’t upgraded trellis-cli yet! So I got v0.6.1 and removed the .trellis folder and ran trellis init and received an error:

[ **----** @------MBP: **~/Documents/projects/-----/websites/------.com/trellis** **(staging)** ] $ trellis init

Creating virtualenv in /Users/-----/Documents/projects/------/websites/-------.com/trellis/.trellis/virtualenv

Error creating virtualenv: exit status 3

an empty .trellis folder is created but nothing in it.

edit: the trellis init command works fine if I uninstall virtualenv… when I reinstall and run trellis init again… i get the error.

Any idea what could be going on?

1 Like

Interesting, thanks for trying it out.

Does virtualenv work fine if you run it manually? Oh if you literally used the value /usr/local/Cellar/python@2/2.7.15_1/bin then that’s probably the problem. You also need the binary itself:

VIRTUALENV_PYTHON=/usr/local/Cellar/python@2/2.7.15_1/bin/python virtualenv .trellis/virtualenv

Assuming that works, trellis init should…

btw you can run which python or which python3 to easily get the full path. You can even do ‘export VIRTUALENV_PYTHON=`which python`’

Thanks Scott… that’s hopefully it. I’ll try that out on Monday.

Am I putting “export” before the command you wrote and virtualenv .trellis/virtualenv after the location in the same command?

Thanks!

It’s an either or:

export VIRTUALENV_PYTHON=/usr/local/Cellar/python@2/2.7.15_1/bin/python

This sets the env var for the duration of that shell/terminal session

VIRTUALENV_PYTHON=/usr/local/Cellar/python@2/2.7.15_1/bin/python virtualenv .trellis/virtualenv

This sets the env var for that command only

Ok… super close here I think.

I made sure I had the newest ansible on my system and ran a deploy on old site and it did not work.

I then ran ‘export VIRTUALENV_PYTHON=/usr/local/bin/python’ and trellis init and no issues. I then ran ‘trellis exec ansible --version’ and got the older version of trellis I put in requirements.txt… AWESOME!

Then I ran ‘trellis deploy staging site.com’ and got the response and error:
Running command => ./bin/deploy.sh staging site.com

PLAY [Ensure necessary variables are defined] **********************************
 [WARNING]: You Ansible version is 2.7.5 but this version of Trellis has only
been tested for compatability with Ansible 2.4.0.0 -> 2.4.3.0. It is advisable
to check for Trellis updates or downgrade your Ansible version.


TASK [Ensure environment is defined] *******************************************
skipping: [localhost]

PLAY [Test Connection] *********************************************************

TASK [connection : Require manual definition of remote-user] *******************
skipping: [xxx.xxx.124.81]

TASK [connection : Specify preferred HostKeyAlgorithms for unknown hosts] ******
/bin/sh: grep: command not found
System info:
  Ansible 2.7.5; Darwin
  Trellis at "Support git url format `ssh://user@host/path/to/repo`"
---------------------------------------------------
An unhandled exception occurred while templating '{{ openssh_6_5_plus |
ternary('ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-
ed25519,ssh-rsa', 'ssh-rsa-cert-v01@openssh.com,ssh-rsa') }}'. Error was a
<class 'ansible.errors.AnsibleError'>, original message: An unhandled
exception occurred while templating '{{ (lookup('pipe', 'ssh -V 2>&1')) |
regex_replace('(.*OpenSSH_([\d\.]*).*)', '\2') | version_compare('6.5', '>=')
}}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An
unhandled exception occurred while running the lookup plugin 'pipe'. Error
was a <class 'ansible.errors.AnsibleError'>, original message:
lookup_plugin.pipe(ssh -V 2>&1) returned 127
fatal: [xxx.xxx.124.81]: FAILED! => {}
	to retry, use: --limit @/Users/------/Documents/projects/-------/websites/trellis/deploy.retry

PLAY RECAP *********************************************************************
xxx.xxx.124.81              : ok=0    changed=0    unreachable=0    failed=1   
localhost                  : ok=0    changed=0    unreachable=0    failed=0   

2019/10/07 10:39:10 exit status 2

So I tried to activate the virtualenv myself by going into /trellis/.trellis/virtualenv and running ‘source bin/activate’ And it was working because it said (virtualenv) in front of my bash location line or whatever it’s called.

I ran ansible --version and got the correct one I needed and then cd …/…/ back into my trellis folder and ran: ‘ansible-playbook deploy.yml -e “site=site.com env=staging”’

This worked fine with no errors!

So it seems like trellis deploy is having some sort of ssh issue while ansible deploy after activated virtualenv is not having that issue.

Any ideas?

Thanks!

/bin/sh: grep: command not found is interesting.
What are the outputs of which grep on your local machine and the remote server?

Locally in virtualenv and after I deactivated… /usr/bin/grep
Remote… /bin/grep

Also… not sure if it matters but server is running Ubuntu 16.04.5

Thanks!

how about ssh -V on your local machine and the remote server?

local - ssh -V OpenSSH_7.9p1, LibreSSL 2.7.3
virtualenv - ssh -V OpenSSH_7.9p1, LibreSSL 2.7.3
remote - ssh -V OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g 1 Mar 2016

Thanks,
Josh

Maybe related:

With Trellis b53f5e6 plus this change:

  // vagrant.default.yml
- vagrant_box: 'bento/ubuntu-18.04'
+ vagrant_box: 'bento/ubuntu-16.04'

vagrant up stuck at

==> default: Bindfs seems to not be installed on the virtual machine, installing now

But it works fine if reverting to bento/ubuntu-18.04

ping @swalkinshaw

I’m not sure how to rule out the version of ubuntu right now… have to think of that for a minute.

Also, why would it work fine when manually activating virtualenv but not when using trellis-cli deploy?

Oh this might be due to https://github.com/roots/trellis-cli/pull/74

Try upgrading to v0.6.2 which I released

1 Like

SUCCESS!!!

Upgrading to 0.6.2 worked. SO it was the PATH issue.

Thank you so much for working with me on this!

So using requirements.txt and trellis-cli seems like a great and easy option to use sites that use older versions of trellis and newer sites on the same system.

1 Like

:tada: yay I’m glad you got it all working. Thanks for testing it out and you helped identify a few bugs!

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