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 Zero Provisioner reports itself as being Chef Solo? #5072

Closed
tknerr opened this issue Dec 28, 2014 · 7 comments · Fixed by #5077
Closed

Chef Zero Provisioner reports itself as being Chef Solo? #5072

tknerr opened this issue Dec 28, 2014 · 7 comments · Fixed by #5077

Comments

@tknerr
Copy link
Contributor

tknerr commented Dec 28, 2014

Wondering if this is as intended -- it's confusing at least...

This is my Vagrantfile:

Vagrant::configure("2") do |config|
  config.vm.define :foo do | foo_config |
    foo_config.vm.box = "ubuntu/precise32"
    foo_config.vm.provision :chef_zero do |chef|
      chef.cookbooks_path = "./cookbooks"
      chef.add_recipe "hello"
    end
  end 
end

On vagrant up it outputs this:

...
==> foo: Running provisioner: chef_zero...
    foo: Installing Chef (latest)...
Generating chef JSON and uploading...
==> foo: Running chef-solo...
==> foo: stdin: is not a tty
==> foo: [2014-12-28T00:22:03+00:00] INFO: Started chef-zero at http://localhost:8889 with repository at /tmp/vagrant-chef-4/chef-solo-1
==> foo:   One version per cookbook
==> foo: [2014-12-28T00:22:03+00:00] INFO: Forking chef instance to converge...
==> foo: [2014-12-28T00:22:03+00:00] INFO: *** Chef 12.0.3 ***
==> foo: [2014-12-28T00:22:03+00:00] INFO: Chef-client pid: 2121
==> foo: [2014-12-28T00:22:04+00:00] INFO: Setting the run_list to ["recipe[hello]"] from CLI options
==> foo: [2014-12-28T00:22:04+00:00] INFO: Run List is [recipe[hello]]
==> foo: [2014-12-28T00:22:04+00:00] INFO: Run List expands to [hello]
==> foo: [2014-12-28T00:22:04+00:00] INFO: Starting Chef Run for vagrant-ubuntu-precise-32
==> foo: [2014-12-28T00:22:04+00:00] INFO: Running start handlers
==> foo: [2014-12-28T00:22:04+00:00] INFO: Start handlers complete.
==> foo: [2014-12-28T00:22:04+00:00] INFO: Chef Run complete in 0.028230979 seconds
==> foo: [2014-12-28T00:22:04+00:00] INFO: Skipping removal of unused files from the cache
==> foo: [2014-12-28T00:22:04+00:00] INFO: Running report handlers
==> foo: [2014-12-28T00:22:04+00:00] INFO: Report handlers complete

It's the ==> foo: Running chef-solo... line that is confusing.

It should read ==> foo: Running chef-zero instead...

@sethvargo
Copy link
Contributor

Hi @tknerr

This is not a bug. Chef Zero is a subclass (subset) of Chef Solo both in Vagrant and Chef land. As you can see here, the only difference is the local_mode attribute, which tells Chef to run an in-memory Chef Server adjacent to the Chef Solo run.

We can certainly improve the message, but this is the intended behavior of the provisioner.

@tknerr
Copy link
Contributor Author

tknerr commented Dec 29, 2014

Thanks @sethvargo.

One thing just got clear to me:

  • chef-zero exists as a binary (in ChefDK at least), but it does not initiate chef run but rather starts the in-memory chef zero server
  • so as you said there ain't no such thing as a chef-zero provisioner

However, I'm sill confused that it's a sublcass of Chef-Solo even though it's a chef client run. Especially since --local-mode is a parameter to chef-client and not chef-solo:

C:\Repos\_github\bills-kitchen\target\build\repo\tmp>chef-solo --help | grep local

C:\Repos\_github\bills-kitchen\target\build\repo\tmp>chef-solo --help | grep zero

C:\Repos\_github\bills-kitchen\target\build\repo\tmp>chef-client --help | grep local
    -z, --local-mode                 Point chef-client at local repository

C:\Repos\_github\bills-kitchen\target\build\repo\tmp>chef-client --help | grep zero
        --chef-zero-host HOST        Host to start chef-zero on
        --chef-zero-port PORT        Port to start chef-zero on

@tknerr
Copy link
Contributor Author

tknerr commented Dec 29, 2014

Trying to understand how chef is being called with the :chef_zero provisioner.

When started in debug mode, you can see the actual command which is chef-solo indeed (there's no sign of --local-mode or -z yet):

...
==> foo: Running chef-solo...
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: chef-solo -c /tmp/vagrant-chef-3/solo.rb -j /tmp/vagrant-chef-3/dna.json (sudo=true)
...

Still, it initiates a chef client run against an inmemory chef zero server:

...
DEBUG ssh: stdout: [2014-12-29T12:48:52+00:00] INFO: Starting chef-zero on port 8889 with repository at repository at /tmp/vagrant-chef-3/chef-solo-1
  One version per cookbook

[2014-12-29T12:48:52+00:00] INFO: Forking chef instance to converge...
[2014-12-29T12:48:52+00:00] INFO: *** Chef 11.8.2 ***
[2014-12-29T12:48:52+00:00] INFO: Chef-client pid: 2156
[2014-12-29T12:48:52+00:00] INFO: Setting the run_list to ["recipe[hello]"] from JSON
[2014-12-29T12:48:52+00:00] INFO: Run List is [recipe[hello]]
[2014-12-29T12:48:52+00:00] INFO: Run List expands to [hello]
[2014-12-29T12:48:52+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-32
[2014-12-29T12:48:52+00:00] INFO: Running start handlers
...

The "secret" lies in the solo.rb config - which finally sets local mode to true:

vagrant@vagrant-ubuntu-trusty-32:~$ cat  /tmp/vagrant-chef-3/solo.rb | grep local
local_mode true

@tknerr
Copy link
Contributor Author

tknerr commented Dec 29, 2014

So I got it know how it works, but it might be confusing for others too.

Especially since in the chef docs --local-mode is clearly associated with chef-client and not chef-solo:

@sethvargo
Copy link
Contributor

@tknerr did you see #5077?

@tknerr
Copy link
Contributor Author

tknerr commented Dec 30, 2014

@sethvargo looks good to me and will probably avoid the confusion for most users 👍

Whoever wants to look behind the vagrant console output will have to dig into the code anyway and eventually find out what we discussed above (or even find this ticket first ;-))

Thanks!

@darkn3rd
Copy link

Maybe rename the provisioner to chef_solo_zero. 😸

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

Successfully merging a pull request may close this issue.

3 participants