Hi,
I'm new to provy, and I've been experimenting with setting up a simple Flask app on a Vagrant VM. As is generally best practice, I want to create a virtualenv for the app, but I'm having difficulty getting it working with pip. Here's my provyfile.py, mostly copied from the getting started code.
from provy.core import Role
from provy.more.debian import VirtualenvRole, PipRole, UserRole
class MyServer(Role):
def provision(self):
with self.using(UserRole) as role:
role.ensure_user('wibble', identified_by='foobar', is_admin=True)
self.update_file('simpleserver.py', '/home/wibble/simpleserver.py', owner='wibble', sudo=True)
with self.using(PipRole) as pip, self.using(VirtualenvRole) as venv:
venv.user = 'wibble'
with venv('serverenv2'):
pip.set_user('wibble')
pip.ensure_requirements_installed('requirements.txt')
servers = {
'test': {
'myserver': {
'address': '192.168.0.100',
'user': 'vagrant',
'roles': [
MyServer
]
}
}
}
What I would like is for the virtualenv serverenv2 to be created for user wibble, and then for pip to do its thing with requirements.txt
What I get, however, is this:
Info: Provy is running using the 'test' set of servers.
*************************************
Provisioning vag...@192.168.0.100...
*************************************
[12:44:35] Group wibble not found! Creating...
[12:44:35] Group wibble created!
[12:44:35] User wibble not found! Creating...
[12:44:35] User wibble created!
[12:44:35] Hashes differ => None! Copying simpleserver.py to server 192.168.0.100!
[vag...@192.168.0.100] put: /var/folders/gh/wm64c4k94fbgb0v58syr2jnm0000gn/T/tmpNrnbh2 -> /home/wibble/simpleserver.py [12:44:36] "change_file_owner" is deprecated, please use "change_path_owner" instead.
[12:44:36] Updating aptitude sources...
[12:44:42] Aptitude sources up-to-date
[12:44:43] curl is not installed (via aptitude)! Installing...
[12:44:48] curl is installed (via aptitude).
[12:44:48] python-setuptools is not installed (via aptitude)! Installing...
[12:44:52] python-setuptools is installed (via aptitude).
[12:44:53] python-dev is not installed (via aptitude)! Installing...
[12:45:09] python-dev is installed (via aptitude).
[12:45:13] virtualenv is not installed (via pip)! Installing...
[12:45:20] virtualenv installed!
[12:45:20] virtualenvwrapper is not installed (via pip)! Installing...
[12:45:46] virtualenvwrapper installed!
[vag...@192.168.0.100] out: load_entry_point('virtualenv==1.8.4', 'console_scripts', 'virtualenv')() [vag...@192.168.0.100] out: File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 964, in main [vag...@192.168.0.100] out: File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1065, in create_environment [vag...@192.168.0.100] out: File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1236, in install_python [vag...@192.168.0.100] out: File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 406, in mkdir
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: virtualenv /home/vagrant/.virtualenvs/serverenv2
Executed: sudo -S -p 'sudo password:' -u "wibble" /bin/bash -l -c "virtualenv /home/vagrant/.virtualenvs/serverenv2"
Aborting.
I'm clearly missing something, because the virtualenv doesn't get created for any user.
Regards,
John