我正在使用Opscode的application_python食谱,并试图部署一个Django应用程序。 我需要为这个项目使用Python 2.7,但是看起来virtualenv的创build是通过默认的python2.6完成的,我不打算在系统上安装它。 因此,运行chef-client时出现以下错误:
[Fri, 08 Jun 2012 16:55:35 +0000] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env] (/var/chef/cache/cookbooks/python/providers/virtualenv.rb line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '3' ---- Begin output of virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env ---- STDOUT: The executable python2.6 (from --python=python2.6) does not exist STDERR: ---- End output of virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env ---- Ran virtualenv --python=python2.6 /opt/apps/trippingbear/shared/env returned 3
对于厨师,我非常(非常)新,而且还没有如何改变它的想法。 默认好像是在cookbooks/python/resources/virtualenv.rb设置了attribute :interpreter, :default => 'python2.6' 。 我已经尝试在我的节点和环境中设置默认值,如下所示,但没有成功:
default_attributes( "python" => { "virtualenv" => { "interpreter" => "python2.7" } } )
我确定这是可configuration的,但我不知道如何去做。 我怎么设置不正确?
我总是在我的部署食谱中明确地创build我的virtualenv,然后根据需要引用这个virtualenv。 例如:
venv_dir = node['some_identifier']['virtualenv_dir'] python_virtualenv venv_dir do interpreter "python" # use system default python, not 2.6 action :create end python_pip "django" do version "1.4" action :install virtualenv venv_dir end
很显然,这是使用python食谱中的python_virtualenv资源,所以python食谱将需要列在你的食谱内。