Skip to content

Instantly share code, notes, and snippets.

@cyberswat
Last active June 1, 2016 18:16
Show Gist options
  • Save cyberswat/8cb36e7f6fc6bb42cad3 to your computer and use it in GitHub Desktop.
Save cyberswat/8cb36e7f6fc6bb42cad3 to your computer and use it in GitHub Desktop.
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
template new_resource.name do
group new_resource.group
mode new_resource.mode
owner new_resource.owner
source new_resource.source
cookbook new_resource.cookbook
variables new_resource.variables
end
notifies :reload, 'service[apache2]'
new_resource.updated_by_last_action(true)
end
action :delete do
directory new_resource.path do
action :delete
recursive false
end
new_resource.updated_by_last_action(true)
end
Recipe: apache2_test::basic_web_app
* directory[/var/www/basic_web_app] action create
[2014-07-30T20:48:45+00:00] INFO: Processing directory[/var/www/basic_web_app] action create (apache2_test::basic_web_app line 26)
[2014-07-30T20:48:45+00:00] DEBUG: found target_mode == nil, so no mode was specified on resource, not managing mode
[2014-07-30T20:48:45+00:00] DEBUG: found target_uid == nil, so no owner was specified on resource, not managing owner
[2014-07-30T20:48:45+00:00] DEBUG: found target_gid == nil, so no group was specified on resource, not managing group
(up to date)
* file[/var/www/basic_web_app/index.html] action create[2014-07-30T20:48:45+00:00] INFO: Processing file[/var/www/basic_web_app/index.html] action create (apache2_test::basic_web_app line 30)
[2014-07-30T20:48:45+00:00] DEBUG: file[/var/www/basic_web_app/index.html] checksumming file at /var/www/basic_web_app/index.html.
[2014-07-30T20:48:45+00:00] DEBUG: calculating checksum of /tmp/.index.html20140730-26173-xxakgt to compare with 75bbad16af4a9cc88cfff0b49b0175da3c953dd88c525361135c7c7f04e140f7
[2014-07-30T20:48:45+00:00] DEBUG: found target_mode == nil, so no mode was specified on resource, not managing mode
[2014-07-30T20:48:45+00:00] DEBUG: found target_uid == nil, so no owner was specified on resource, not managing owner
[2014-07-30T20:48:45+00:00] DEBUG: found target_gid == nil, so no group was specified on resource, not managing group
(up to date)
* apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf] action create[2014-07-30T20:48:45+00:00] INFO: Processing apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf] action create (apache2_test::basic_web_app line 70)
================================================================================
Error executing action `create` on resource 'apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf]'
================================================================================
NoMethodError
-------------
No resource or method named `notifies' for `Chef::Provider::Apache2WebApp ""'
Cookbook Trace:
---------------
/tmp/kitchen/cookbooks/apache2/providers/web_app.rb:35:in `block in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cookbooks/apache2_test/recipes/basic_web_app.rb
70: apache2_web_app "#{node['apache']['dir']}/sites-available/#{name}.conf" do
71: variables template_variables
72: end
73:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cookbooks/apache2_test/recipes/basic_web_app.rb:70:in `from_file'
apache2_web_app("/etc/httpd/sites-available/basic_web_app.conf") do
action :create
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name :apache2_test
recipe_name "basic_web_app"
variables {:port=>80, :server_name=>"basic-web-app", :server_aliases=>["basic-web-app.localhost.dev"], :docroot=>"/var/www/basic_web_app", :directories=>{"/var/www/basic_web_app"=>{"Options"=>"FollowSymLinks", "AllowOverride"=>"None", "Order"=>"allow,deny", "Allow"=>"from all"}, "/"=>{"Options"=>"FollowSymLinks", "AllowOverride"=>"None"}}, :log_level=>"info", :error_log=>"/var/log/httpd/basic_web_app-error.log", :custom_log=>"/var/log/httpd/basic_web_app-access.log combined", :rewrite_engine=>"on", :rewrite_log=>"/var/log/httpd/basic_web_app-rewrite.log", :rewrite_log_level=>0, :rewrite=>[{"conditions"=>["%{HTTP_HOST} !^basic-web-app.localhost.dev [NC]", "%{HTTP_HOST} !^$"], "rules"=>["^/(.*)$ http://basic-web-app.localhost.dev/$1 [L,R=301]"]}]}
mode 420
source "web_app.conf.erb"
cookbook "apache2"
end
[2014-07-30T20:48:45+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-07-30T20:48:45+00:00] DEBUG: Re-raising exception: NoMethodError - apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf] (apache2_test::basic_web_app line 70) had an error: NoMethodError: No resource or method named `notifies' for `Chef::Provider::Apache2WebApp ""'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:47:in `rescue in method_missing'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:44:in `method_missing'
/tmp/kitchen/cookbooks/apache2/providers/web_app.rb:35:in `block in class_from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider.rb:120:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource.rb:637:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepa
ble_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:217:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:221:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:67:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:23:in `load'
/usr/bin/chef-solo:23:in `<main>'
Running handlers:
[2014-07-30T20:48:45+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-07-30T20:48:45+00:00] ERROR: Exception handlers complete
[2014-07-30T20:48:45+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2014-07-30T20:48:45+00:00] DEBUG: NoMethodError: apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf] (apache2_test::basic_web_app line 70) had an error: NoMethodError: No resource or method named `notifies' for `Chef::Provider::Apache2WebApp ""'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:47:in `rescue in method_missing'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:44:in `method_missing'
/tmp/kitchen/cookbooks/apache2/providers/web_app.rb:35:in `block in class_from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/provider.rb:120:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource.rb:637:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:217:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:221:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:67:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:23:in `load'
/usr/bin/chef-solo:23:in `<main>'
Chef Client failed. 0 resources updated in 29.392051107 seconds
[2014-07-30T20:48:45+00:00] ERROR: apache2_web_app[/etc/httpd/sites-available/basic_web_app.conf] (apache2_test::basic_web_app line 70) had an error: NoMethodError: No resource or method named `notifies' for `Chef::Provider::Apache2WebApp ""'
[2014-07-30T20:48:45+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
D Cleaning up local sandbox in /tmp/default-centos-65-sandbox-20140730-16312-10s95e7
>>>>>> Converge failed on instance <default-centos-65>.
>>>>>> Please see .kitchen/logs/default-centos-65.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen/solo.rb --json-attributes /tmp/kitchen/dna.json --log_level debug]
>>>>>> ----------------------
D Converge failed on instance <default-centos-65>.
D ------Exception-------
D Class: Kitchen::InstanceFailure
D Message: Converge failed on instance <default-centos-65>. Please see .kitchen/logs/default-centos-65.log for more details
D ---Nested Exception---
D Class: Kitchen::ActionFailed
D Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen/solo.rb --json-attributes /tmp/kitchen/dna.json --log_level debug]
D ------Backtrace-------
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/driver/ssh_base.rb:112:in `rescue in run_remote'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/driver/ssh_base.rb:108:in `run_remote'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/driver/ssh_base.rb:48:in `block in converge'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/ssh.rb:47:in `initialize'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/driver/ssh_base.rb:43:in `new'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/driver/ssh_base.rb:43:in `converge'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/kitchen-vagrant-0.15.0/lib/kitchen/driver/vagrant.rb:75:in `converge'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:273:in `public_send'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:273:in `block in perform_action'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:308:in `call'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:308:in `synchronize_or_call'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:283:in `block in action'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:282:in `action'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:273:in `perform_action'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:256:in `converge_action'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:246:in `block in transition_to'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:245:in `each'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:245:in `transition_to'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/instance.rb:119:in `converge'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/command.rb:109:in `public_send'
D /home/cyberswat/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/test-kitchen-1.2.1/lib/kitchen/command.rb:109:in `block (2 levels) in run_action'
D ----------------------
@gitmlynch
Copy link

@cyberswat. Did you ever solve this problem. I'm experiencing a similar one.

@nathancolgate
Copy link

@gitmlynch I was having the same problem. My issue was that I was calling notifies outside of a resource block.

Bad:

template "/etc/nginx/sites-available/#{app.fetch("name")}" do
    source 'nginx.conf.erb'
end
notifies :reload, 'service[nginx]', :delayed

Good:

template "/etc/nginx/sites-available/#{app.fetch("name")}" do
    source 'nginx.conf.erb'
    notifies :reload, 'service[nginx]', :delayed
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment