So here's a snippet from my manifest (based on this module: https://github.com/stankevich/puppet-python):
python::virtualenv { $virtualenv_dir:
ensure => present,
version => 'system',
systempkgs => false,
distribute => false,
owner => $user,
group => $group,
}
That works fine when I run puppet apply for the first time. Second time it fails though:
Already using interpreter /usr/bin/python
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in
virtualenv.main()
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
never_download=options.never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1274, in install_python
shutil.copyfile(executable, py_executable)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/usr/local/myapp/venv/bin/python'
This is probably because I have a bunch of background processes running that using the Python binary from virtualenv (Celery workers, uwsgi workers etc).
Is there a way to only init the virtualenv first time? There is no need to run virtualenv command once the directory is created, right?
The following class will create a virtual env. "creates" limits the command to only be run if the virtualenv doesn't exist
Call the class with the following: