Chef-server configuration error Centos-7

Hi Guys,

Chef configuration error on Centos-7 while running the command below on chef-server 12.8.0

#chef-server-ctl reconfigure

[root@chef-server opscode]# cat /var/opt/opscode/local-mode-cache/chef-stacktrace.out
Generated at 2016-09-11 04:39:42 -0400
RuntimeError: Error loading file: /etc/opscode/chef-server.rb:2:in `from_file': undefined method `-' for nil:NilClass
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/private_chef.rb:118:in `rescue in from_file'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/libraries/private_chef.rb:115:in `from_file'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/config.rb:80:in `from_file'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/cookbook_version.rb:233:in `load_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:354:in `load_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:310:in `block in include_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:309:in `each'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:309:in `include_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/default.rb:38:in `from_file'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/cookbook_version.rb:233:in `load_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:354:in `load_recipe'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/run_context.rb:176:in `load'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/client.rb:510:in `setup_run_context'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/client.rb:280:in `run'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/application.rb:268:in `run_with_graceful_exit_option'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/application.rb:244:in `block in run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/application.rb:227:in `run_chef_client'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/application/client.rb:419:in `run_application'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/lib/chef/application.rb:59:in `run'
/opt/opscode/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.19/bin/chef-client:26:in `<top (required)>'
/opt/opscode/embedded/bin/chef-client:23:in `load'
/opt/opscode/embedded/bin/chef-client:23:in `<main>'[root@chef-server opscode]#

Chef-server.rb file is as follows.

[root@chef-server opscode]# cat chef-server.rb
server_name = "chef-server.mylab.com"
api_fqdn chef-server
bookshelf['vip'] = chef-server
nginx['url'] = "https://#{chef-server}"
nginx['server_name'] = chef-server
nginx['ssl_certificate'] = "/var/opt/opscode/nginx/ca/#{chef-server}.crt"
nginx['ssl_certificate_key'] = "/var/opt/opscode/nginx/ca/#{chef-server}.key"
[root@chef-server opscode]#

Kindly help with resolving the issue.

api_fqdn chef-server should be api_fqdn "chef-server" (put the server name in quotes)

cheers,
-Thom

If you’re up to use a variable in your config, use server_name which you’re defining at top of file instead of chef-server.

Or rename the first line variable to chef-server