3

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

Community
  • 1
  • 1
  • Please don't forget to mark an answer as correct! :) – sethvargo Jan 02 '14 at 01:23
  • hummm... I did not found how to do it : ( To be true, the answer helped me, but I stucked in new problems with this python-application cookbook... now I plan to write a lower-level recipe... – Leonardo Leite Jan 06 '14 at 11:13

1 Answers1

2

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.

ukabu
  • 86
  • 4
  • Yes, I had that issue using application_ruby. Changing the order of dependencies seems to have solve the problem. However, I'm not sure anymore. I still have that problem. Are you using Berkshelf and/or Vagrant? – ukabu Oct 29 '13 at 18:10
  • This doesn't seem to work for me, not matter what I re-order or work with. Are you using chef-solo / Berkshelf / Vagrant? Thats my usecase. – stevemac Sep 15 '14 at 07:47
  • I had the same use case. Do you specify versions for your dependencies? – ukabu Sep 15 '14 at 10:00
  • I didn't have versions initially, but found this question and have added them like suggested, but still no dice.. Have tried both 3.0.0 and 3.0.1. Have also tried not adding the application dependancy, deleting the Berkshelf cache. I'm sure something is missing but can't work out what. Any pointers greatly appreciated. – stevemac Sep 15 '14 at 11:16
  • Can you post your metadata.rb? Do you have other dependencies? – ukabu Sep 15 '14 at 11:20
  • Your dependencies seems OK to me. Do you use the latest version of chef? I was using the latest version that was available a year ago. It may be possible that the application_python had issue with the current version of chef (this cookbook hasn't been updated in a long time) – ukabu Sep 15 '14 at 12:10
  • Actually seem to have found it, it was a problem with my recipe. By removing the 'database' section taken from the example, it seems to have worked.. Thanks for your help. – stevemac Sep 15 '14 at 13:14