Writing my first vagrant chef solo recipe I figured something simple, like changing the hostname. In the vagrant file, I have this;
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "../../chef/cookbooks"
chef.roles_path = "../../chef/roles"
chef.data_bags_path = "../../chef/data_bags"
chef.json = { :hostname => "foofoo" }
chef.add_recipe "myrecipe"
in myrecipe/recipes/default.rb;
myvar = node[:hostname]
template "/tmp/myfile" do
source "myfile.erb"
owner "root"
group "root"
mode 0644
variables(
:myvar => myvar
)
end
in myrecipe/templates/default/myfile.erb;
<%= @myvar %>
This wouldn't actually work. /tmp/myfile kept ending up with the real hostname from /etc/hostname. After banging my head a long while, I hit on these changes;
in the vagrant file;
chef.json = { :myhostname => "foofoo" }
in the recipe file;
myvar = node[:myhostname]
So, it seems ':hostname' is special somehow, but try as I might, I can't find any documentation that explains why, or how to override it, or what other 'special' values there might be available.
Most of the documentation seems to assume some level of competence I haven't reached yet. So, I might have seen the answer and not recognized it. Can anyone point me to the 'absolute beginner' docs that would explain this?