I created a new trellis site the other day and saw that the requirements step had changed slightly and that when I went through it, it upgrade my version of ansible.
I just tried to deploy and older site and received: ‘PlaybookCLI’ object has no attribute ‘options’.
After searching around, I realized it was the ansible upgrade so I downgraded and all is well.
I will need to create more sites soon and am not sure what to do here.
I initiated trellis to one of my projects and now am redoing the requirements step of my newer version and ran into this error which I did not experience the first time my Ansible was updated:
Found existing installation: ansible 2.7.5
Uninstalling ansible-2.7.5:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/usr/local/lib/python2.7/site-packages/ansible-2.7.5-py2.7.egg-info/PKG-INFO’
Consider using the --user option or check the permissions.
Any idea why this is happening now? My command was: pip install -r requirements.txt
You just ran pip install -r requirements.txt on its own? If you could list the steps you took/commands you ran in order it might help figure out what happened.
Oh yeah sudo can break things. Ideally you should never run pip with sudo. I’m not entirely sure how to get out of that broken permission state once you’re in it.
However, if you ran trells init then you can run trellis exec pip install -r requirements.txt instead to make sure you’re in the activated virtualenv
edit: trellis init runs pip install automatically too
Ok so I took a chance and just sudo pip uninstall and then ran pip requirements from the new version of trellis and installed the new version of ansible fine.
I then did a deploy how I did before for an older trellis site and received the error I received yesterday… so I was back to where I wanted to be.
I then ran trellis deploy and received this:
Running command => ./bin/deploy.sh staging -----.com
PLAY [Ensure necessary variables are defined] **********************************
**[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin**
**(<ansible.plugins.callback./Users/----/Documents/projects/----/web**
**sites/trellis/lib/trellis/plugins/callback/vars.CallbackModule object at**
**0x7fc000267c50>): 'dict' object has no attribute 'iteritems'**
**[WARNING]: You Ansible version is 2.7.13 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] *******************************************
**[WARNING]: Failure using method (v2_runner_on_skipped) in callback plugin**
**(<ansible.plugins.callback.output.CallbackModule object at 0x7fc0086ebd68>):**
**name 'unicode' is not defined**
PLAY [Test Connection] *********************************************************
TASK [connection : Require manual definition of remote-user] *******************
TASK [connection : Specify preferred HostKeyAlgorithms for unknown hosts] ******
/bin/sh: grep: command not found
**[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin**
**(<ansible.plugins.callback.output.CallbackModule object at 0x7fc0086ebd68>):**
**name 'unicode' is not defined**
to retry, use: --limit @/Users/-----/Documents/projects/-----/websites/trellis/deploy.retry
PLAY RECAP *********************************************************************
------ : ok=0 changed=0 unreachable=0 failed=1
localhost : ok=0 changed=0 unreachable=0 failed=0
2019/10/02 15:30:15 exit status 2
Because it mentioned ansible 2.4.3.0, I downgraded in my projects requirements.txt and ran the trellis exec command you posted before. It downgraded fine.
When I ran deploy again, I received:
Running command => ./bin/deploy.sh staging ------.com
ERROR! Unexpected Exception, this is probably a bug: invalid syntax (__init__.py, line 96)
to see the full traceback, use -vvv
2019/10/02 15:36:12 exit status 250
I feel like we are close… any idea why neither ansible version is working?
Ok, it looks like a virtualenv needs to be created with the wanted python version in the command. I guess I have python 3 installed on here but 2 is still the default version but trellis-cli ound 3 and used 3.
How can I make trellis-cli create a virtualenv with python 2.7 without deleting python 3?
Unfortunately not yet. It defaults to python3 if installed. Although the Python version itself shouldn’t really matter
Ok, it looks like a virtualenv needs to be created with the wanted python version in the command.
I’m not sure what command you mean. Is it running deploy? If so, you should use trellis-cli’s deploy command. I wasn’t really clear on this, but if you’re trying to use it’s built-in venv feature, then all commands should be run through it as well.
It has almost every common command built-in and for those that aren’t, you can run anything through trellis exec <anything>.
So in theory just using trellis-cli should make everything work without having to care about python version, ansible, etc.
Yep I am running trellis-cli’s deploy and getting the errors above.
I looked into ‘dict’ object has no attribute ‘iteritems’** and name ‘unicode’ is not defined* and it seems that these commands are in python 2 but not 3.
I checked python version on my mac with python --version and got 2.7.15 and when I use trellis exec python --version I get 3.7.0
I’m thinking that could be the issue?
Did the python version that trellis uses change in the last year to year and a half?
Also, from reading your latest reply, it is possible you only saw my last response… i had written a few as I found new things in my research… so you can see the error messages and extra info above when you have the time… and really thanks a lot for helping me get through it.
Did the python version that trellis uses change in the last year to year and a half?
Okay yeah this makes sense, sorry. I think I assumed your projects couldn’t be that old Definitely looks like they are old enough not to have the Python 3 support we’ve added over time. For a while now Trellis supports both versions.
Sorry I’ve led you down a bit of a rabbit-hole then without asking some initial questions. Let me add an option to specify the python used for init quickly. I’ll push a new version tonight hopefully.
In the meantime you can always try to get pip working as usual without trellis-cli
; ) Yeah the one I was deploying to was probably created June-Aug 18. I never updated these projects because they always worked and didn’t want to break anything.
Thank you very much for being so responsive on this and please don’t go crazy trying to fix anything too fast. I can always upgrade and downgrade as needed if I have to work on any new projects or mess with virtualenv myself and that post I linked to in my initial post.
And also glad you pointed me to trellis-cli which is going to make my life so much easier for new projects and also to manage my older projects and virtual environments… freakin awesome that you created it!