hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

config.vm.provision "chef_zero" is chef-solo not chef-client #5619

Closed kcd83 closed 9 years ago

kcd83 commented 9 years ago
==> default: [2015-04-21T23:39:30+01:00] INFO: *** Chef 12.2.1 ***
==> default: [2015-04-21T23:39:30+01:00] INFO: Chef-client pid: 3738
..
==> default: Error expanding the run_list:
==> default: ================================================================================
==> default:
==> default: Unexpected Error:
==> default: -----------------
==> default: Chef::Exceptions::IllegalVersionConstraint: Environment cookbook version constraints not allowed in chef-solo

I would expect this to do what Kitchen does

sudo -E /opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --chef-zero-port 8889 --json-attributes /tmp/kitchen/dna.json` 

I have read https://github.com/mitchellh/vagrant/issues/5072 but don't understand the use of chef-solo rather than chef-client --local-mode. What am I missing?

kcd83 commented 9 years ago

Issue might be that I have both installed. If i rename chef-solo i get an error

[root@localhost ~]# find /usr/bin/ -name *chef*
/usr/bin/chef-apply
/usr/bin/OFFchef-solo
/usr/bin/chef-client
/usr/bin/chef-shell
==> default: Detected Chef (12.2.1) is already installed
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

There must be some conflict going on here

sethvargo commented 9 years ago

@kcd83 can you try using a box that does not have Chef pre-installed? I think you have conflicting verisons.

kcd83 commented 9 years ago

Reproduced this on opscode-centos-6.6 and chef/centos-6.5. As for your suggestion I tried puppetlabs/centos-6.6-64-puppet and I still hit the same problem.

kcd83 commented 9 years ago

FYI chef-solo also fails if the environment is missing

  "json_class": "Chef::Environment",
  "chef_type": "environment",

Whereas chef-zero does not

sethvargo commented 9 years ago

Hi @kcd83

Can you please share your complete Vagrantfile? Thanks!

erichelgeson commented 9 years ago

I came across this same issue today using boxcutter centos 65 latest. The new audit-mode is not in solo, but is in client, relavant info in the mailing list - http://lists.opscode.com/sympa/arc/chef/2015-04/msg00221.html

I too would expect it to be chef-client vs chef-solo for local mode.

smudgerdan commented 9 years ago

Taking the code from an example on the chef site in a recipe (https://docs.chef.io/data_bags.html#with-recipes):

users = Chef::DataBag.new
users.name("users")
users.create

sam = {
    "id" => "sam",
    "Full Name" => "Sammy",
    "shell" => "/bin/zsh"
}
databag_item = Chef::DataBagItem.new
databag_item.data_bag("users")
databag_item.raw_data = sam
databag_item.save

sam = data_bag_item("users", "sam")
sam["Full Name"] = "Samantha"
sam.save

I get a error when using the chef_zero provisioner: ERROR: Failed to load data bag item: "users" "sam"

The folder and files are created in the data_bags folder but it seems to have an issue reading it back. The command being called by vagrant is chef-solo -c c:\tmp\vagrant-chef\solo.rb -j c:\tmp\vagrant-chef\dna.json --no-color but if I change it to chef-client -z -c c:\tmp\vagrant-chef\solo.rb -j c:\tmp\vagrant-chef\dna.json --no-color it completes successfully.

I am hosting in Windows and the guest is Windows (in case that makes a difference)

twisty7867 commented 9 years ago

Any ETA for a fix? I can't use this provisioner at present because of this issue - my environments specify cookbook versions, which is incompatible with chef-solo.

dkinzer commented 9 years ago

I'm seeing this too.

kcd83 commented 9 years ago

Sorry guys, this was on me to supply the example.

@sethvargo finally the example https://github.com/kcd83/vagrantnotchefzero

darkn3rd commented 9 years ago

The chef_zero provisioner needs to be use chef-client, or just be purged completely as a provisioner. It is really silly to install the chef-zero server, and then ignore it completely and run chef-solo. That just makes no sense, and it has caused widespread community confusion for newcomers, at least using StackExchange and blogs from google searches as an indicator.

My experience using --debug

==> default: Running chef-zero...
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: chef-solo -c /tmp/vagrant-chef/solo.rb -j /tmp/vagrant-chef/dna.json (sudo=true)
DEBUG ssh: stdout: [2015-06-26T21:18:55+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/c19100fe12f29bf544251f7d7a235dce, /tmp/vagrant-chef/bfad03565fe3ecf680d558e8af341658
  One version per cookbook
  data_bags at /tmp/vagrant-chef/53b0fe0a99cb305e675bc618db68b140/data_bags
  nodes at /tmp/vagrant-chef/8bb0903c9c271b10d5e3f1f69884cc05/nodes
  roles at /tmp/vagrant-chef/d77be995bf05ee56bed651f13f31f647/roles
kcd83 commented 9 years ago

Thanks Seth! On 10/07/2015 4:17 PM, "Seth Vargo" notifications@github.com wrote:

Closed #5619 https://github.com/mitchellh/vagrant/issues/5619 via 4b1847a https://github.com/mitchellh/vagrant/commit/4b1847acf30c8ef46d499c41ed54736277f232aa .

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant/issues/5619#event-352555887.