Cómo utilizar Python LWRP con Opsworks/Chef 11
-
20-12-2019 - |
Pregunta
Soy nuevo en Chef/OpsWorks y estoy intentando una receta sencilla para instalar Django 1.6 en una instancia de Ubuntu 12.04:
python_pip "Django" do
version "1.6"
action :install
end
Mis proveedores/pip.rb y proveedores/virtualenv.rb parecen anular lo que, aparentemente, ya estaba cargado:
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!
Pero cuando intento usar python_pip recibo un error:
ERROR: Caught exception while compiling OpsWorks custom run list: NameError - Cannot find a resource for python_pip on ubuntu version 12.04
He intentado agregar depends "python"
en mi metadata.rb, pero esto no ayudó.Se agradece cualquier sugerencia.
Mi estructura de directorios de mi libro de cocina '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
Solución
No intente modificar el libro de recetas de Python a menos que ya no haga lo que necesita.Su directorio de libros de cocina debería verse como mínimo:
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>
Eso es todo, no es necesario modificar el libro de recetas de Python.Ahora simplemente configure su lista de ejecución en [ "python", "application_cookbook" ]
y estás listo para irte.
Otros consejos
Antes de poder utilizar el python_pip
LWRP, usted necesita tener python en su runlist o include_recipe "python"
dentro de su propia receta.
Aquí un ejemplo en el que se supone que un usuario llamado dj
con un directorio de inicio ya establecido.
# 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