2

我是 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 

我试过添加depends "python"我的 metadata.rb,但这没有帮助。任何建议表示赞赏。

我的食谱“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
4

2 回答 2

2

在您可以使用python_pipLWRP 之前,您需要在您的运行列表或include_recipe "python"您自己的配方中包含 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
于 2013-11-15T17:41:53.193 回答
1

不要尝试修改 python 食谱,除非它还没有满足你的需要。您的食谱目录至少应如下所示:

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 食谱。现在只需将您的运行列表设置为[ "python", "application_cookbook" ]就可以了。

于 2014-03-03T17:43:34.580 回答