Using python_application Chef cookbook

1k Views Asked by At

I'm trying to use the django resource provided by the application_python cookbook: https://github.com/opscode-cookbooks/application_python

If a follow the example provided in https://github.com/opscode-cookbooks/application_python/blob/master/examples/recipes-packaginator.rb and having declared depends application_python on mt metadata, I got the following error:

No resource found for django. Tried application_django, application_python_django, django

So I tried to follow the advice here in Including a Chef LWRP from another cookbook using "application_python_django" resource rather than just "django". And I got:

No resource found for application_python_django. Tried application_application_python_django, application_python_application_python_django, application_python_django

Interesting is that if I remove the application resource and leave only the application_python_django resource, the complain is:

You must supply a name when declaring a application_python_django resource

!!! So it seems the resource was found. So, if a declare the resource name, the recipe is executed, but no action is performed do the django resource (in deed, a lot of parameters are missing, that were in the application resource).

Ah, if I remove the application and leave only the resource as django, a also get:

Cannot find a resource for django on ubuntu version 12.04

Well, I'm a quite lost.

The initial try for my recipe was:

application 'radar_parlamentar' do
  path       '$HOME/radar_parlamentar'
  owner      'radar'
  repository 'https://github.com/leonardofl/radar_parlamentar.git'
  revision   'master'

  django do
    debug             true
    collectstatic     'build_static --noinput'
    database do
    database  'radarparlamentar'
      adapter   'mysql'
      username  'radarparlamentar'
      password  'secret'
    end
  end

  gunicorn do
    only_if { node['roles'].include? 'packaginator_application_server' }
    app_module :django
    port 8080
  end
end

tks, Leonardo

1

There are 1 best solutions below

7
On

Try adding a dependency to the "application" cookbook AFTER the dependency to the "application_python" cookbook.

Finally found the why it's doing that. It is related to the dependencies in metadata.rb.

To solve the problem, you MUST ensure that the version of the dependencies in your cookbook DOES NOT conflict with the ones in the depended on cookbooks.

In the _application_python_ cookbook, the dependency to the application cookbook is specified :

depends "application", "~> 3.0"

If your cookbook metadata.rb specify the dependency as

depends "application", "~> 4.0"
depends "application_python", "~>3.0.1"

Then Chef will not be able load application cookbook as the dependencies for application conflicts. The one from the _application_python_ cookbook requires version greater or equal than 3.0 and lower than 4.0. The one in your cookbook requires version greater or equal than 4.0 and lower than 5.0.

If you don't specify a version in your cookbook, you'll still get a conflict as Berkshelf (or another dependency manager) will download the latest.

So you'll need to have your metadata.rb look like :

depends "application", "~> 3.0"
depends "application_python", "~>3.0.1"

to make it work.

This answers also applies for those of have the same issue with :

  • application_ruby
  • application_java

or any other cookbooks that have dependencies that you also have in yours.