title: overriding hostname in vagrant chef solo recipe
body: <p>Writing my first vagrant chef solo recipe I figured something simple, like changing the hostname.  In the vagrant file, I have this;</p>
  
  <pre><code>  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 =&gt; "foofoo" }
      chef.add_recipe "myrecipe"
  </code></pre>
  
  <p>in myrecipe/recipes/default.rb;</p>
  
  <pre><code>myvar = node[:hostname]
  
  template "/tmp/myfile" do
      source "myfile.erb"
      owner "root"
      group "root"
      mode 0644
      variables(
          :myvar =&gt; myvar
      )
  end
  </code></pre>
  
  <p>in myrecipe/templates/default/myfile.erb;</p>
  
  <pre><code>&lt;%= @myvar %&gt;
  </code></pre>
  
  <p>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;</p>
  
  <p>in the vagrant file;</p>
  
  <pre><code>chef.json = { :myhostname =&gt; "foofoo" }
  </code></pre>
  
  <p>in the recipe file;</p>
  
  <pre><code>myvar = node[:myhostname]
  </code></pre>
  
  <p>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.  </p>
  
  <p>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? </p>