schubergphilis / vagrant-chef-zero

Vagrant Plugin for Chef Zero
Apache License 2.0
91 stars 41 forks source link

Fails to authenticate to chef zero server #74

Closed vilisseranen closed 8 years ago

vilisseranen commented 9 years ago

With this Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.chef_zero.enabled = true
  config.chef_zero.chef_repo_path = "chef"

  config.vm.box = 'ubuntu/trusty32'
  config.vm.provision :chef_client do |chef|
    chef.run_list = []
  end
end

It fails with

The following berks command failed to execute:

    /usr/bin/berks upload --berksfile /home/vilisseranen/co-rabbitmq/Berksfile --no-freeze --force

The stdout and stderr are shown below:

    stdout: E, [2015-07-27T09:33:11.214641 #6659] ERROR -- : Ridley::Errors::ClientKeyFileNotFoundOrInvalid: client key is invalid or not found at: '/etc/chef/client.pem'
E, [2015-07-27T09:33:11.214751 #6659] ERROR -- : /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.2.0/lib/ridley/client.rb:144:in `initialize'

I thought the authentication was handled by the plugin so I don't understand why I can't connect.

miguelaferreira commented 9 years ago

When you run vagrant up, do you see a .zero-knife.rb file on the local directory? If so, could you post the contents?

Also, do you have the latest version of the plugin?

miguelaferreira commented 9 years ago

@vilisseranen Any update on this issue? Or can I close it?

lesha4ever commented 8 years ago

Hi. I have latest version of plugins vagrant-chef-zero-2.0.0 vagrant-berkshelf-4.1.0 vagrant_1.8.1

and the same error.

==> default: Updating Vagrant's Berkshelf... ==> default: Resolving cookbook dependencies... ==> default: Fetching 'cs-backup' from source at . ==> default: Using cs-backup (0.1.0) from source at . ==> default: Vendoring cs-backup (0.1.0) to /home/user/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160120-2586-1m7b2ms-default/cs-backup ==> default: Uploading cookbooks to http://10.1.1.19:4000 The following berks command failed to execute:

/usr/bin/berks upload --berksfile /home/user/chef/chef-repo/cookbooks/cs-backup/Berksfile --no-freeze --force

The stdout and stderr are shown below:

stdout: E, [2016-01-20T14:31:09.868415 #4373] ERROR -- : Ridley::Errors::ClientKeyFileNotFoundOrInvalid: client key is invalid or not found at: '/etc/chef/client.pem'

E, [2016-01-20T14:31:09.868501 #4373] ERROR -- : /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-4.3.2/lib/ridley/client.rb:144:in `initialize'

» cat .zero-knife.rb

        chef_server_url 'http://10.1.1.19:4000'
        node_name 'zero-host'
        client_key '/tmp/fake_key/fake.pem'

» ls -lha /tmp/fake_key/fake.pem -rw-r--r-- 1 user user 1,7K січ 20 14:25 /tmp/fake_key/fake.pem

miguelaferreira commented 8 years ago

Hi @lesha4ever

My best guess is that vagrant-berkshellf plugin is not picking up on the server configuration that vagrant-chef-zero creates (here: https://github.com/schubergphilis/vagrant-chef-zero/blob/master/lib/vagrant-chef-zero/env_helpers.rb#L29). This could be for several reasons, not blaming the berks plugin.

If you would like to contribute with a PR to integrate with vagrant-berkshelf, that would be great. If not I'm afraid all I can offer you now is a workaround.

The workaround would be:

  1. disable the vagrant-berkshelf plugin in your vagrant file
  2. use berks command line tool to package all the cookbook dependencies: berks vendor TARGET_DIR
  3. configure vagrant-chef-zero to upload the cookbooks from config.chef_zero.cookbooks = "TARGET_DIR"

Can you please try this? I will be happy to assist you if you get stuck.

lesha4ever commented 8 years ago

Thanks,

Looks like this workaround works.

But I do not understand where I should to contact for fixing this bug?

miguelaferreira commented 8 years ago

Great to hear that it worked.

This is the palace for asking these things. However, it is not a bug. A bug would be something not working in the plugin. What you would like to see is this plugin integrate with another plugin (berkshelf). That's a feature request, and since we have no planned roadmap for the plugin, it will be difficult to implement it. New features have been added by the people that need them, when they need them. That's why I say, if you really need the integration with berks, then you are more than welcome to make a pull request to add that, and I will be very happy to help you by reviewing, and testing your change,

lesha4ever commented 8 years ago

Many thanks!