我在清单中使用这个类:
python::virtualenv { $virtualenv_dir:
ensure => present,
version => 'system',
systempkgs => false,
distribute => false,
owner => $user,
group => $group,
}
第一次效果很好。
问题是我有几个使用venv / bin / python文件的守护进程的芹菜工人。
当我第二次申请清单时,我得到:
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'
如果还没有创建venv目录,是否有可能只运行virtualenv命令?
或者你会建议什么?我不想在申请木偶清单时阻止我的芹菜工人。
答案 0 :(得分:1)
只有在尚未创建特定文件时,才能使用exec
参数运行creates
资源的命令:
exec { 'mycommand':
command => '/usr/bin/something a b c',
creates => '/var/lib/xxx';
}
仅当/var/lib/xxx
不存在时才会运行该命令。