Having written my first recipe for a solo tramp, I realized something as simple as changing the host name. In a stray 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 does not work. / tmp / myfile all the time ends with the real host name from / etc / hostname. After I hit my head, I pressed on these changes;
in a stray file;
chef.json = { :myhostname => "foofoo" }
in the recipe file;
myvar = node[:myhostname]
So it seems that: "hostname" is somehow special, but as I can, I cannot find any documentation that explains why or how to override it, or what other "special" values may be available.
Most of the documentation seems to imply a certain level of competency that I have not yet reached. So, I could see the answer and did not recognize it. Can someone point me to the “absolute beginners” who will explain this?
source share