I am seeing a similar issue, but with RubyBlock. The ruby_block resource actually executes fine, but the Chef run fails.
Here’s the ruby_block that sends the notification:
ruby_block "run_block" do
block do
Chef::Log.info("Sending notification")
Chef::Log.info("Response in message: #{node['aws']['lambda']['sample_function']['resp_json'][this_env]}")
notifies :create, "ruby_block[deploy_sample_lambda_function]", :immediately
end
end
Versions:
/opt/chefdk/embedded/bin/ruby --version
ruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-darwin13.0]
vagrant -v
Vagrant 1.8.5
chef -v
Chef Development Kit Version: 0.17.17
chef-client version: 12.13.37
delivery version: master (f68e5c5804cd7d8a76c69b926fbb261e1070751b)
berks version: 4.3.5
kitchen version: 1.11.1
The error:
NoMethodError - undefined method `declared_key' for "ruby_block[deploy_sample_lambda_function]":String
Trace:
==> default: * ruby_block[deploy_sample_lambda_function] action create * ruby_block[deploy_sample_lambda_function] action create[2016-09-22T09:52:30+00:00] INFO: Processing ruby_block[deploy_sample_lambda_function] action create (my__lambda::sample_function line 38)
==> default: [2016-09-22T09:52:30+00:00] DEBUG: Providers for generic ruby_block resource enabled on node include: [Chef::Provider::RubyBlock]
==> default: [2016-09-22T09:52:30+00:00] DEBUG: Provider for action create on resource ruby_block[deploy_sample_lambda_function] is Chef::Provider::RubyBlock
==> default: [2016-09-22T09:52:30+00:00] INFO: ** Running /usr/local/bin/aws lambda create-function --region us-west-2 --function-name sample_function --zip-file fileb:///root/files/opsdev/lambda/sample_function.py.zip --role arn:aws:iam::xxxxxxxxxxx:role/lambda_basic_execution --description "sample lambda function for CB testing" --handler sample_function.lambda_handler --runtime python2.7 --timeout 5 --memory-size 256
==> default: [2016-09-22T09:52:31+00:00] INFO: ShellOut response JSON: {
==> default: "CodeSha256": "LVsg+VEGEm8xXFYly8o5uiF7Puewjni/C9DhM3H9/w0=",
==> default: "FunctionName": "sample_function",
==> default: "CodeSize": 411,
==> default: "MemorySize": 256,
==> default: "FunctionArn": "arn:aws:lambda:us-west-2:xxxxxxxxxx:function:sample_function",
==> default: "Version": "$LATEST",
==> default: "Role": "arn:aws:iam::xxxxxxxxxxx:role/lambda_basic_execution",
==> default: "Timeout": 5,
==> default: "LastModified": "2016-09-22T09:52:31.387+0000",
==> default: "Handler": "sample_function.lambda_handler",
==> default: "Runtime": "python2.7",
==> default: "Description": "sample lambda function for CB testing"
==> default: }
==> default:
==> default: [2016-09-22T09:52:31+00:00] INFO: Saving response of create-function sample_function
==> default: [2016-09-22T09:52:31+00:00] INFO: response: {
==> default: "CodeSha256": "LVsg+VEGEm8xXFYly8o5uiF7Puewjni/C9DhM3H9/w0=",
==> default: "FunctionName": "sample_function",
==> default: "CodeSize": 411,
==> default: "MemorySize": 256,
==> default: "FunctionArn": "arn:aws:lambda:us-west-2:xxxxxxxxxxx:function:sample_function",
==> default: "Version": "$LATEST",
==> default: "Role": "arn:aws:iam::xxxxxxxxxxx:role/lambda_basic_execution",
==> default: "Timeout": 5,
==> default: "LastModified": "2016-09-22T09:52:31.387+0000",
==> default: "Handler": "sample_function.lambda_handler",
==> default: "Runtime": "python2.7",
==> default: "Description": "sample lambda function for CB testing"
==> default: }
==> default:
==> default: [2016-09-22T09:52:31+00:00] INFO: error:
==> default: [2016-09-22T09:52:31+00:00] INFO: exitcode: 0
==> default: [2016-09-22T09:52:31+00:00] INFO: ruby_block[deploy_sample_lambda_function] called
==> default:
==> default: - execute the ruby block deploy_sample_lambda_function
==> default: - execute the ruby block deploy_sample_lambda_function
==> default:
==> default: * ruby_block[run_block] action run * ruby_block[run_block] action run[2016-09-22T09:52:31+00:00] INFO: Processing ruby_block[run_block] action run (my__lambda::sample_function line 74)
==> default: [2016-09-22T09:52:31+00:00] DEBUG: Providers for generic ruby_block resource enabled on node include: [Chef::Provider::RubyBlock]
==> default: [2016-09-22T09:52:31+00:00] DEBUG: Provider for action run on resource ruby_block[run_block] is Chef::Provider::RubyBlock
==> default: [2016-09-22T09:52:31+00:00] INFO: Sending notification
==> default: [2016-09-22T09:52:31+00:00] INFO: Response in message: {
==> default: "CodeSha256": "LVsg+VEGEm8xXFYly8o5uiF7Puewjni/C9DhM3H9/w0=",
==> default: "FunctionName": "sample_function",
==> default: "CodeSize": 411,
==> default: "MemorySize": 256,
==> default: "FunctionArn": "arn:aws:lambda:us-west-2:xxxxxxxxxxx:function:sample_function",
==> default: "Version": "$LATEST",
==> default: "Role": "arn:aws:iam::xxxxxxxxxxx:role/lambda_basic_execution",
==> default: "Timeout": 5,
==> default: "LastModified": "2016-09-22T09:52:31.387+0000",
==> default: "Handler": "sample_function.lambda_handler",
==> default: "Runtime": "python2.7",
==> default: "Description": "sample lambda function for CB testing"
==> default: }
==> default:
==> default: [2016-09-22T09:52:31+00:00] INFO: ruby_block[run_block] called
==> default:
==> default: - execute the ruby block run_block
==> default: - execute the ruby block run_block
==> default:
==> default: [2016-09-22T09:52:31+00:00] INFO: ruby_block[run_block] sending create action to ruby_block[deploy_sample_lambda_function] (immediate)
==> default: [2016-09-22T09:52:31+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default: [2016-09-22T09:52:31+00:00] DEBUG: Re-raising exception: NoMethodError - undefined method `declared_key' for "ruby_block[deploy_sample_lambda_function]":String
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/run_context.rb:245:in `before_notifications'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:52:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:77:in `block in run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:75:in `each'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:75:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `block (2 levels) in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `each'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:96:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:669:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:664:in `catch'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:664:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:703:in `converge_and_save'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:283:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:302:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:290:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:290:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:255:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:243:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:450:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:450:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:434:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:60:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/solo.rb:226:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default:
==> default: Running handlers:
==> default:
==> default: Running handlers:
==> default: [2016-09-22T09:52:31+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: Running handlers complete
==> default:
==> default: [2016-09-22T09:52:31+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 2 resources updated in 07 seconds
==> default: Chef Client failed. 2 resources updated in 07 seconds
==> default: [2016-09-22T09:52:31+00:00] DEBUG: Server doesn't support resource history, skipping resource report.
==> default: [2016-09-22T09:52:31+00:00] DEBUG: Audit Reports are disabled. Skipping sending reports.
==> default: [2016-09-22T09:52:31+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-09-22T09:52:31+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-09-22T09:52:31+00:00] DEBUG: NoMethodError: undefined method `declared_key' for "ruby_block[deploy_sample_lambda_function]":String
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/run_context.rb:245:in `before_notifications'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:52:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:77:in `block in run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:75:in `each'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:75:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `block (2 levels) in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `each'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:97:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/runner.rb:96:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:669:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:664:in `catch'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:664:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:703:in `converge_and_save'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/client.rb:283:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:302:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:290:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:290:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:255:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:243:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:450:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:450:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/client.rb:434:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application.rb:60:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/lib/chef/application/solo.rb:226:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.77/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: [2016-09-22T09:52:31+00:00] ERROR: undefined method `declared_key' for "ruby_block[deploy_sample_lambda_function]":String
==> default: [2016-09-22T09:52:31+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
Any help with this will be appreciated.
Cheers!