Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

recipes/default.rb: Initialize afw/rules attribute. #17

Merged
merged 1 commit into from

3 participants

@dave-shawley

default['afw']['rules'] is not necessarily initialized before it is referenced in the default recipe. This seems to only occur when running in chef solo.

Stacktrace:

Generated at Mon Aug 05 12:51:54 +0000 2013
NoMethodError: undefined method `each' for nil:NilClass
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/afw/recipes/default.rb:39:in `from_file'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/locust/recipes/default.rb:14:in `from_file'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:79:in `load'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `load'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:198:in `setup_run_context'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:418:in `do_run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:230:in `run_application'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `loop'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `run_application'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-solo:25
/opt/vagrant_ruby/bin/chef-solo:19:in `load'
/opt/vagrant_ruby/bin/chef-solo:19
@dave-shawley dave-shawley recipes/default.rb: Initialize afw/rules attribute.
`default['afw']['rules']` is not necessarily initialized before it is
referenced in the default recipe.  This seems to only occur when running
in chef solo.

Stacktrace:

    Generated at Mon Aug 05 12:51:54 +0000 2013
    NoMethodError: undefined method `each' for nil:NilClass
    /tmp/vagrant-chef-1/chef-solo-1/cookbooks/afw/recipes/default.rb:39:in `from_file'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
    /tmp/vagrant-chef-1/chef-solo-1/cookbooks/locust/recipes/default.rb:14:in `from_file'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:79:in `load'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `each'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `load'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:198:in `setup_run_context'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:418:in `do_run'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:230:in `run_application'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `loop'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `run_application'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
    /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-solo:25
    /opt/vagrant_ruby/bin/chef-solo:19:in `load'
    /opt/vagrant_ruby/bin/chef-solo:19
92b1e2f
@djt5019

:+1: - This has fixed some issues I've had when using AFW on chef-solo.

@jvehent
Owner

@djt5019 : I don't have a staging env to test that at the moment. Can you confirm it works with chef-server?

@djt5019

Sorry for the delay @jvehent, I've tried it out locally and it works like a charm. Both Chef-Server and Chef-Solo work just fine with it.

@jvehent jvehent merged commit ce60ebc into jvehent:master
@jvehent
Owner

Thanks :) merging it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 5, 2013
  1. @dave-shawley

    recipes/default.rb: Initialize afw/rules attribute.

    dave-shawley authored
    `default['afw']['rules']` is not necessarily initialized before it is
    referenced in the default recipe.  This seems to only occur when running
    in chef solo.
    
    Stacktrace:
    
        Generated at Mon Aug 05 12:51:54 +0000 2013
        NoMethodError: undefined method `each' for nil:NilClass
        /tmp/vagrant-chef-1/chef-solo-1/cookbooks/afw/recipes/default.rb:39:in `from_file'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
        /tmp/vagrant-chef-1/chef-solo-1/cookbooks/locust/recipes/default.rb:14:in `from_file'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/cookbook_version.rb:558:in `load_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:79:in `load'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `each'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/run_context.rb:75:in `load'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:198:in `setup_run_context'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:418:in `do_run'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:230:in `run_application'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `loop'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `run_application'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
        /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-solo:25
        /opt/vagrant_ruby/bin/chef-solo:19:in `load'
        /opt/vagrant_ruby/bin/chef-solo:19
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  recipes/default.rb
View
1  recipes/default.rb
@@ -36,6 +36,7 @@ class Chef::Recipe
end
end
+node.default['afw']['rules'] ||= {}
node['afw']['rules'].each do |name,params|
Chef::Log.info("AFW: processing rule '#{name}'")
if process_rule(node, name, params)
Something went wrong with that request. Please try again.