Closed CVTJNII closed 8 years ago
Hi @CVTJNII
Please take a look at the Common Chef Options: https://docs.vagrantup.com/v2/provisioning/chef_common.html. I think it solves all the things you need.
@sethvargo Unless I'm missing something I don't believe so, the common arguments are for the provisioner inside the box, whereas this issue is for the knife commands run outside the container to remove the box from an external chef server. The line in question (https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/chef/provisioner/chef_client.rb#L132) builds and executes a knife command, I don't see where it uses any common settings. The 'knife' command name is a hardcoded string and no options are appended, unless there is some deep magic in Vagrant::Util::Subprocess.execute I'm missing.
+1 I'm running into the same problem. Alternatively (or additionally) would it be possible to specify an arbitrary cleanup command/script?
@sethvargo Those Chef options work for chef-client
calls within the container, but since the client cleanup tasks are made via a knife
call outside of the container, they use the default knife.rb from the host machine.
@CVTJNII One way I sort of get around this is to have a "local" knife.rb file but that gets in the way when I'm making actual knife
calls from that directory, since it uses that configuration file instead of the one in the default path.
Why do the cleanup knife
calls have to run outside of the container? Does the cleanup phase run after the VM is destroyed?
The node and client termination now happens in the VM, using the same configuration as the chef server is setup to use. If you need further customization beyond that, please take a look at the vagrant-butcher plugin. Thanks!
In the Chef-client provisioner the system knife is called to remove node and client details from the server:
https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/chef/provisioner/chef_client.rb#L132
While this is fine if Vagrant is interacting with a chef server which is configured in ~/.chef/knife.rb, it fails if the user is trying to test against a test chef server which does not use the default knife configuration.
Please expose an argument to append options (say, append an array of user specified options) to the command array so that a knife config file can be specified in the Vagrant file. This will allow Vagrant testing with Chef servers using a custom knife config.
Also, it would also be nice to make the knife binary configurable for even more edgy edge cases where the user needs to specify which program to use for knife.