How can I redefine the name of the chef node in the stroller?

I am developing a cook cookbook that I am testing with Vagrant and chef-solo. Recipes look at node.name to make specific decisions. To test the various options for this, I would like to override this attribute for test runs from Vagrant. So I tried

 Vagrant.configure("2") do |config| ... config.vm.provision :chef_solo do |chef| ... chef.json = { 'name' => 'randomhostname', } end end 

but it seems to have no effect.

I understand that the name attribute by default has a hostname attribute that ohai controls (see also this question ), but is there a way to override the name attribute?

+4
source share
3 answers

You should be able to use:

 Vagrant.configure("2") do |config| ... config.vm.provision :chef_solo do |chef| ... chef.node_name = 'node_name' ... end end 
+5
source

If the default name matches the vm host name, could you just change the host name?

 config.vm.hostname = "new.host.name" 
+3
source

No, there is no way - this is the so-called automatic attribute and therefore always has the highest priority and overwrites everything that you specify. Is it possible to use a different attribute, or which cookbook are you going to convince that the name node is different from what the chef thinks?

+1
source

Source: https://habr.com/ru/post/1481187/


All Articles