0

I am using this github repo to understand the working of Berkshelf when used along with Amazon Opsworks. The basic idea behind what i am trying is if i mention apache2 as a dependency in berksfile for my phpapp recipe then it will automatically manage the dependencies for apache2 which itself is a dependency for phpapp. when i try this with AWS opsworks i get the following error.

   ================================================================================
   Error executing action `run` on resource 'execute[enable mod_proxy for apache-tomcat binding]'
   ================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/sbin/a2enmod proxy ----
STDOUT: 
STDERR: ERROR: Module proxy does not exist!
---- End output of /usr/sbin/a2enmod proxy ----
Ran /usr/sbin/a2enmod proxy returned 1


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_java/recipes/apache_tomcat_bind.rb

1: execute 'enable mod_proxy for apache-tomcat binding' do
2:   command '/usr/sbin/a2enmod proxy'
3:   not_if do
4:     ::File.symlink?(::File.join(node['apache']['dir'], 'mods-enabled', 'proxy.load')) || node['opsworks_java']['tomcat']['apache_tomcat_bind_mod'] !~ /\Aproxy/
5:   end
6: end
7: 



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_java/recipes/apache_tomcat_bind.rb:1:in `from_file'

execute("enable mod_proxy for apache-tomcat binding") do
action "run"
retries 0
retry_delay 2
command "/usr/sbin/a2enmod proxy"
backup 5
returns 0
cookbook_name "opsworks_java"
recipe_name "apache_tomcat_bind"
not_if { #code block }
end
Subham Tripathi
  • 2,683
  • 6
  • 41
  • 70

1 Answers1

1

Add metadata insted of cookbook "apache2" to your Berksfile, with that in place Berkshelf will add your local cookbook to list of local cookbooks, and it's dependencies from metadata.rb

From berkshelf.com:

The metadata keyword is like saying gemspec in Bundler’s Gemfile. It says,
“There is a metadata.rb file within the same relative path of my Berksfile”.
This allows you to resolve a Cookbook’s dependencies that you are currently
working on just like you would resolve the dependencies of a Gem that 
you are currently working on with Bundler.

Here is similar issue.

Community
  • 1
  • 1
rastasheep
  • 10,416
  • 3
  • 27
  • 37
  • Hmm it seems that mod_proxy isn't included in default_modules, you can include it with `include_recipe 'apache2::mod_proxy'`. Btw i have founded that resource from your log is not in you cookbook, but it's in some ["opsworks-example-cookbooks" repo]( https://github.com/amazonwebservices/opsworks-example-cookbooks/blob/master/tomcat/recipes/apache_tomcat_bind.rb#L14) is maybe that left over on your instance/runlist ? – rastasheep Nov 28 '14 at 08:58
  • also i didnt understand, where do i need to make the changes ? as in where should i add these lines "include_recipe 'apache2::mod_proxy'" – Subham Tripathi Nov 28 '14 at 09:13
  • In your recipe just below `include_recipe "apache2"` line, because default recipe setups apache2 and all other recipes from apache2 cookbook will just add mods on top of it. – rastasheep Nov 28 '14 at 09:28
  • 2
    But please check your nodes runlist, because resource 'execute[enable mod_proxy for apache-tomcat binding]' is not in your cookbook, from where is that included? – rastasheep Nov 28 '14 at 09:30
  • i tried that both ways above it and below it but both of them didnt work. – Subham Tripathi Nov 28 '14 at 09:31
  • can we please discuss it in chat because i am kind of stuck badly ? – Subham Tripathi Nov 28 '14 at 09:31
  • i have mentioned the run list in the custom json textbox of stack in opsworks like -> {"run_list":["recipe[phpapp]"]}, but after adding that it showed another error being run_list attribute not properly used. where to put the run_list in opsworks ? – Subham Tripathi Nov 28 '14 at 09:45
  • OpsWorks has specific way of managing runlists it's [described here]( http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-assigningcustom.html). – rastasheep Nov 28 '14 at 10:04
  • oh.. that i am already doing, in my custom recipe section of the layer, i have added phpapp::default in setup lifecycle. – Subham Tripathi Nov 28 '14 at 10:07
  • Can you try to use Ubuntu instead Amazon Linux, there is some reports on web that this happens only on Amazon Linux? – rastasheep Nov 28 '14 at 10:14
  • ya i tried that too but that is also giving errors well they are different than the one amazon linux gives ! – Subham Tripathi Nov 28 '14 at 10:16