我是Chef / OpsWorks的新手,我正在尝试在Ubuntu 12.04实例上安装Django 1.6的简单方法:
python_pip "Django" do
version "1.6"
action :install
end
我的providers / pip.rb和providers / virtualenv.rb似乎覆盖了表面上已经加载的内容:
DEBUG: Loading cookbook python's providers from /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/pip.rb
DEBUG: Loaded contents of /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/pip.rb into a provider named python_pip defined in Chef::Provider::PythonPip
DEBUG: Loading cookbook python's providers from /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/virtualenv.rb
DEBUG: Loaded contents of /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/virtualenv.rb into a provider named python_virtualenv defined in Chef::Provider::PythonVirtualenv
DEBUG: Loading cookbook python's providers from /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/pip.rb
INFO: PythonPip light-weight provider already initialized -- overriding!
DEBUG: Loaded contents of /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/pip.rb into a provider named python_pip defined in Chef::Provider::PythonPip
DEBUG: Loading cookbook python's providers from /opt/aws/opsworks/releases/20131107153140_213/site-cookbooks/python/providers/virtualenv.rb
INFO: PythonVirtualenv light-weight provider already initialized -- overriding!
但是当我尝试使用python_pip时,我收到一个错误:
ERROR: Caught exception while compiling OpsWorks custom run list: NameError - Cannot find a resource for python_pip on ubuntu version 12.04
我尝试在我的metadata.rb中添加depends "python"
,但这没有帮助。任何建议都表示赞赏。
我的食谱'python'的目录结构:
.
├── python
│ ├── attributes
│ │ └── default.rb
│ ├── metadata.rb
│ ├── providers
│ │ ├── pip.rb
│ │ └── virtualenv.rb
│ ├── recipes
│ │ ├── default.rb
│ │ ├── django.rb
│ │ ├── package.rb
│ │ ├── pip.rb
│ │ ├── source.rb
│ │ └── virtualenv.rb
│ ├── specs
│ │ └── configure_spec.rb
│ └── templates
│ └── default
└── README.md
答案 0 :(得分:2)
在使用python_pip
LWRP之前,您需要在运行列表中使用python,或者在自己的配方中使用include_recipe "python"
。
这是一个假设您有一个名为dj
的用户已经设置了主目录的示例。
# Note that the recipe will install Python, setuptools and pip
include_recipe "python"
# Create a virtual environment
python_virtualenv '/home/dj/virtenv' do
interpreter "python2.7"
owner 'dj'
group 'dj'
action :create
end
# Install Django to a virtualenv
python_pip "django" do
virtualenv '/home/dj/virtenv'
user 'dj'
group 'dj'
action :install
end
答案 1 :(得分:1)
不要尝试修改python cookbook,除非它还没有做你需要的东西。您的cookbook目录至少应该是:
cookbooks/
├─python/ <clone of https://github.com/poise/python>
|
└─application_cookbook/
├─recipes/
| └─default.rb <containing the resource declaration you have in the question>
└─metadata.rb <with a `depends "python"` statement in it>
那就是它,不需要修改python cookbook。现在只需将您的运行列表设置为[ "python", "application_cookbook" ]
,您就可以了。