Opsworks/Chef 11에서 Python LWRP를 사용하는 방법
-
20-12-2019 - |
문제
저는 Chef/OpsWorks를 처음 사용하며 Ubuntu 12.04 인스턴스에 Django 1.6을 설치하기 위한 간단한 방법을 시도하고 있습니다.
python_pip "Django" do
version "1.6"
action :install
end
내 공급자/pip.rb 및 공급자/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
해결책
필요한 것을 아직하지 않는 한 아직 파이썬 요리 책을 수정하려고하지 마십시오.CookBooks 디렉토리는 최소한의 모습을보아야합니다.
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>
.
파이썬 요리 책을 수정할 필요가 없습니다.이제 RunList를 [ "python", "application_cookbook" ]
로 설정하고 잘 가려면 좋습니다.
다른 팁
사용하기 전에 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
제휴하지 않습니다 StackOverflow