Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chef Solo now giving "TypeError: no implicit conversion of nil into String" #245

Open
sleenen opened this issue Nov 21, 2016 · 3 comments
Open

Comments

@sleenen
Copy link

sleenen commented Nov 21, 2016

I had Chef vault working with chef solo in vagrant, I updated my gems and now when running vagrant provision I'm getting:

no implicit conversion of nil into String

when trying to get item

key = ChefVault::Item.load("secrets", "certificate.key")

Seems like it can't load the data from the vault anymore.
I'm not sure where to look :S any help is appreciated.

This is the stacktrace:

Generated at 2016-11-21 10:27:45 +0000
TypeError: no implicit conversion of nil into String
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb:143:in `initialize'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb:143:in `open'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb:143:in `secret'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb:74:in `load_keys'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb:268:in `load'
/var/chef/cache/cookbooks/nginx/recipes/default.rb:52:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/cookbook_version.rb:233:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context.rb:338:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context/cookbook_compiler.rb:141:in `block in compile_recipes'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/run_context.rb:187:in `load'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:510:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:280:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:294:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:247:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:235:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:434:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/solo.rb:226:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:54:in `load'
/usr/bin/chef-solo:54:in `<main>'
@sleenen
Copy link
Author

sleenen commented Nov 21, 2016

Checked line 143 or item.rb (/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-vault-2.9.0/lib/chef-vault/item.rb)

private_key = OpenSSL::PKey::RSA.new(File.open(@client_key_path).read())

I tried puts @client_key_path

Seems @client_key_path is empty/nil?

@sleenen
Copy link
Author

sleenen commented Nov 21, 2016

I've tried hardcoding to point to /etc/chef/my.pem. When doing that, all seems to work as expected again.

@youhyunkim
Copy link

Agreed @client_key_path shouldn't be empty/nil.
But if you need a cleaner workaround for now, you can just pass the client_key_path as a param to ChefVault::Item.load.

so something like
key = ChefVault::Item.load("vault", "vault_item", client_key_path: '/path/to/client.pem')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants