Originate/cookbooks

Chef::Exceptions::CookbookNotFound when starting instance on OpsWorks

Closed this issue · 7 comments

I'm getting a Chef::Exceptions::CookbookNotFound in the setup recipe when trying to start the instance from Amazon OpsWorks with the message "Cookbook play2 not found. If you're loading play2 from another cookbook, make sure you configure the dependency in your metadata"

I'm using a Stack with Ubuntu 14.04 LTS and instance store root device. I'm using a custom cookbook https://github.com/Antena/play-opsworks, which uses your play2 cookbook: https://github.com/Antena/play-opsworks/blob/master/app/Berksfile

I also added a custom JSON:

{
  "play2": {
    "version": "2.1.3",
    "http_port": 80,
    "conf": {
      "application": {
        "langs": "en"
      }
    }
  }
}

I've added the app::setup to the Setup recipe and app::deploy to the Deploy recipe, as indicated in http://blog.originate.com/blog/2014/10/02/how-to-deploy-play-framework-on-aws-opsworks/#comment-1714849007

I'm using the sample play app for now: https://github.com/Bowbaq/sample-play-app.git

You can find the full stacktrace here: http://pastebin.com/quEgydua

I am new to Chef. Is there some way to locally verify that all dependencies are included? If not, any ideas why is it failing to find Play's cookbook?

Thanks!

Thanks for creating the issue, I'll try to look into it today.

Actually, it looks like in the sample repository there are a couple lines in the metadata.rb file that may be causing this problem: https://github.com/Originate/play-sample-opsworks/blob/master/app/metadata.rb#L8-L9

Could you try adding that and see if it does the trick?

Thanks @Bowbaq but where should I add that? In my app/metadata.rb?
I already tried that, and I'm getting the same error.

I think you need to re-run the berks vendoring step in order for it to work properly (after adding the dependency)

berks vendor /tmp/cookbooks -b app/Berksfile && cp -rf /tmp/cookbooks/* .

Ok, we're getting close... I think re-running the berks vendoring fixed the play2 dependency issue (:+1:), but I'm getting another error now while trying to start the app.

It's trying to open /etc/init.d/functions which is not found:

[2014-12-01T19:17:02+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-12-01T19:17:02+00:00] ERROR: Running exception handlers
[2014-12-01T19:17:02+00:00] ERROR: Exception handlers complete
[2014-12-01T19:17:02+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2014-12-01T19:17:02+00:00] ERROR: execute[restart app] (app::deploy line 147) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of sudo service app restart ----
STDOUT: 
STDERR: /etc/init.d/app: 18: .: Can't open /etc/init.d/functions
---- End output of sudo service app restart ----
Ran sudo service app restart returned 2
[2014-12-01T19:17:02+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I think that command comes from the play2 cookbook's app_initd.rb: https://github.com/Originate/play-sample-opsworks/blob/master/play2/templates/default/app_initd.erb#L18

Maybe some OS issue? I'm trying with Ubuntu 14.04 LTS

FYI, here's the full stracktrace: http://pastebin.com/JztwVZzg

I think that the style of init script used in the cookbook is tailored to Amazon Linux. I'm not sure what tweaks are necessary for Ubuntu.

At a glance, it looks like we're not using any of the functions in there though. You could try just commenting that line out in your copy of the cookbook and see what happens.

Changed the /etc/init.d/functions to the equivalent Ubuntu call and it worked! Antena/play-opsworks@262f523