NoMethodError: ruby_block[bootstrap-chef-server-data] (private-chef::bootstrap line 33) had an error: NoMethodError: undefined method `[]' for nil:NilClass
introlive opened this issue · comments
Cookbook version
chef-server (5.1.0)
Chef-client version
Chef Client, version 12.17.44
Platform Details
CentOS release 6.4 (Final)
Scenario:
Trying to use "chef-server-ctl reconfigure" on node after bootstrap it using cookbook "chef-server (5.1.0)"
I got the error :
[2017-01-14T01:58:26-05:00] FATAL: NoMethodError: ruby_block[bootstrap-chef-server-data] (private-chef::bootstrap line 33) had an error: NoMethodError: undefined method `[]' for nil:NilClass
Steps to Reproduce:
I am trying to build a testing chef server on my own VPS provided by alpharacks CentOS release 6.4 (Final)
I use my local workstation to bootstrap it (using Chef Manage as server) and set your cookbook as its runlist . all looks good .
$ knife bootstrap myip -x archerwang -P mypasswd --sudo -N chefserver -r 'recipe[mychefserver]'
Node chefserver exists, overwrite it? (Y/N) y
Client chefserver exists, overwrite it? (Y/N) y
Creating new client for chefserver
Creating new node for chefserver
Starting the first Chef Client run...
Starting Chef Client, version 12.17.44
[2017-01-14T01:52:49-05:00] WARN: [inet6] no ip address on venet0:0
resolving cookbooks for run list: ["mychefserver"]
Synchronizing Cookbooks:
- mychefserver (0.1.0)
- chef-server (5.1.0)
- chef-ingredient (0.21.2)
- compat_resource (12.16.3)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 4 resources
Recipe: chef-server::default
- ruby_block[ensure node can resolve API FQDN] action run (skipped due to not_if)
- chef_ingredient[chef-server] action install
Recipe:- chef_gem[mixlib-install] action install (up to date)
- ruby_block[stop chef run] action nothing (skipped due to action :nothing)
- remote_file[/var/chef/cache/chef-server-core-12.11.1-1.el6.x86_64.rpm] action create (up to date)
* yum_package[chef-server] action install (up to date)
(up to date)
Recipe: chef-server::default - file[/var/chef/cache/chef-server-core.firstrun] action create (up to date)
- chef_ingredient_ingredient_config[chef-server] action render
- directory[/etc/opscode] action create (up to date)
- file[/etc/opscode/chef-server.rb] action create (up to date)
(up to date)
Running handlers:
Running handlers complete
Chef Client finished, 0/10 resources updated in 46 seconds
Then i run chef-server-ctl reconfigure on my VPS .
below is the error details:
Recipe: private-chef::bootstrap
-
execute[/opt/opscode/bin/chef-server-ctl start postgresql] action run
- execute /opt/opscode/bin/chef-server-ctl start postgresql
-
execute[/opt/opscode/bin/chef-server-ctl start oc_bifrost] action run
- execute /opt/opscode/bin/chef-server-ctl start oc_bifrost
-
ruby_block[bootstrap-chef-server-data] action run
================================================================================
Error executing actionrun
on resource 'ruby_block[bootstrap-chef-server-data]'**NoMethodError
undefined method `[]' for nil:NilClass**
Cookbook Trace:
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:97:in
create_superuser_in_erchef' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:50:in
block in bootstrap'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:55:inblock in with_service_connection' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:44:in
with_connection'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:52:inwith_service_connection' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:49:in
bootstrap'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb:35:in `block (2 levels) in from_file'Resource Declaration:
In /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb
33: ruby_block "bootstrap-chef-server-data" do
34: block do
35: ChefServerDataBootstrap.new(node).bootstrap
36: end
37: not_if { OmnibusHelper.has_been_bootstrapped? }
38: notifies :restart, 'service[opscode-erchef]'
39: end
40:Compiled Resource:
Declared in /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb:33:in `from_file'
ruby_block("bootstrap-chef-server-data") do
action [:run]
retries 0
retry_delay 2
default_guard_interpreter :default
block_name "bootstrap-chef-server-data"
declared_type :ruby_block
cookbook_name "private-chef"
recipe_name "bootstrap"
block #Proc:0x00000007a36b08@/var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb:34
not_if { #code block }
endPlatform:
x86_64-linux
Running handlers:
[2017-01-14T01:58:26-05:00] ERROR: Running exception handlers
Running handlers complete
[2017-01-14T01:58:26-05:00] ERROR: Exception handlers complete
Chef Client failed. 21 resources updated in 04 minutes 10 seconds
[2017-01-14T01:58:26-05:00] FATAL: Stacktrace dumped to /var/opt/opscode/local-mode-cache/chef-stacktrace.out
[2017-01-14T01:58:26-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-01-14T01:58:26-05:00] FATAL: NoMethodError: ruby_block[bootstrap-chef-server-data] (private-chef::bootstrap line 33) had an error: NoMethodError: undefined method `[]' for nil:NilClass
Expected Result:
[2017-01-14T01:58:26-05:00] FATAL: NoMethodError: ruby_block[bootstrap-chef-server-data] (private-chef::bootstrap line 33) had an error: NoMethodError: undefined method `[]' for nil:NilClass
Actual Result:
[root@www html]# more /var/opt/opscode/local-mode-cache/chef-stacktrace.out
Generated at 2017-01-14 01:58:26 -0500
NoMethodError: ruby_block[bootstrap-chef-server-data] (private-chef::bootstrap line 33) had an error: NoMethodError: undefined method []' for nil:NilClass /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:97:in
create_superuser_in_erchef'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:50:in block in bootstrap' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:55:in
block in with_service_connection'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:44:in with_connection' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:52:in
with_service_connection'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:49:in bootstrap' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb:35:in
block (2 levels) in from_file'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:35:in call' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:35:in
block in action_run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/mixin/why_run.rb:52:in add_action' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider.rb:176:in
converge_by'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:34:in action_run' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider.rb:145:in
run_action'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource.rb:622:in run_action' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:69:in
run_action'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:in block (2 levels) in converge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:in
each'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:in block in converge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/resource_list.rb:94:in
block in execute_each_resource'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:114:in call' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:114:in
call_iterator_block'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:85:in step' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:103:in
iterate'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:55:in each_with_index' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/resource_list.rb:92:in
execute_each_resource'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:96:in converge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:670:in
block in converge'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:665:in catch' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:665:in
converge'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:704:in converge_and_save' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:284:in
run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:276:in run_with_graceful_exit_option' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:252:in
block in run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/local_mode.rb:44:in with_server_connectivity' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:235:in
run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application/client.rb:427:in run_application' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:59:in
run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/bin/chef-client:26:in <top (required)>' /opt/opscode/embedded/bin/chef-client:22:in
load'
/opt/opscode/embedded/bin/chef-client:22:in `
Caused by NoMethodError: undefined method
'[]' for nil:NilClass /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:97:in
create_superuser_in_erchef'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:50:inblock in bootstrap' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:55:in
block in with_service_connection'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:44:inwith_connection' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/ec_postgres.rb:52:in
with_service_connection'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/chef_server_data_bootstrap.rb:49:inbootstrap' /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/bootstrap.rb:35:in
block (2 levels) in from_file'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:35:incall' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:35:in
block in action_run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/mixin/why_run.rb:52:inadd_action' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider.rb:176:in
converge_by'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider/ruby_block.rb:34:inaction_run' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/provider.rb:145:in
run_action'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource.rb:622:inrun_action' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:69:in
run_action'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:inblock (2 levels) in converge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:in
each'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:97:inblock in converge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/resource_list.rb:94:in
block in execute_each_resource'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:114:incall' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:114:in
call_iterator_block'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:85:instep' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:103:in
iterate'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/resource_collection/resource_list.rb:92:in
execute_each_resource'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/runner.rb:96:inconverge' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:670:in
block in converge'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:665:incatch' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:665:in
converge'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:704:inconverge_and_save' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/client.rb:284:in
run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:276:inrun_with_graceful_exit_option' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:252:in
block in run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/local_mode.rb:44:inwith_server_connectivity' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:235:in
run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application/client.rb:427:inrun_application' /opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/lib/chef/application.rb:59:in
run'
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/chef-12.17.17/bin/chef-client:26:in<top (required)>' /opt/opscode/embedded/bin/chef-client:22:in
load'
/opt/opscode/embedded/bin/chef-client:22:in `
I figure it out myself , it seems i have some bad caches for chef-server
it works fine after i run "sudo chef-server-ctl cleanse" to clean the data .