1

I have a problem during migration of chef-client 12 to chef-client 14 and seems that the old way to load Providers is different in chef14

Chef::Provider::DeployKeyGithub cannot be load

    deploy_key deploy_key_name do
        provider Chef::Provider::DeployKeyGithub
        path "/home/#{current_user}/.ssh"
        credentials({
            :token => File.read('/root/someid').strip
        })
        repo 'test/test_config'
        owner 'root'
        group 'root'
        mode '0400'
        action :add
    end

Error:

================================================================================

NameError
---------
uninitialized constant Chef::Provider::DeployKeyGithub

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/flume_wrapper/recipes/default.rb:89:in `block in from_file'
  /var/chef/cache/cookbooks/flume_wrapper/recipes/default.rb:88:in `from_file'```

Does anyone knows how is the new way to load a Provider in a recipe for chef14 client?
2
  • deploy_key is not a core Chef resource, you'd better check the cookbook providing this resource, it may not be compatible with chef 14, best way to know would be to try it with chef 13 which should tell deprecations used.
    – Tensibai
    Jan 29 '19 at 15:38
  • It was solved using the new format to load a provider in chef14 Chef::ProviderResolver.new(node, find_resource!("deploy_key[github]"), :nothing).resolve Jan 30 '19 at 19:38
1

This compatibility issue was solved for chef14 with the new load format of a provider in a recipe.

deploy_key deploy_key_name do
      provider Chef::ProviderResolver.new(node, find_resource!("deploy_key[github]"), :nothing).resolve
      path "/home/#{current_user}/.ssh"
      credentials({
          :token => File.read('/root/someid').strip
      })
      repo 'test/test_config'
      owner 'root'
      group 'root'
      mode '0400'
      action :add
  end
0

Unfortunately, I wasn't able to get the cookbook working using the ProviderResolver syntax for loading a provider.

However, I did manage to find an updated fork of the cookbook on GitHub that resolves the Chef 13 deprecations here: https://github.com/alvlapo/cookbook-deploy_key

I believe that should circumvent the issue you're seeing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.