[chef] Re: Where i can find chef server ip and hostname in a recipe for add variable to template


Chronological Thread 
  • From: Mukta Aphale < >
  • To:
  • Subject: [chef] Re: Where i can find chef server ip and hostname in a recipe for add variable to template
  • Date: Wed, 29 May 2013 17:07:53 +0530

One way is to set the values in your client node.
Do a knife node edit and add the values chefserverip and chefserverhostname.
These will be accessible to all recipes.

You can also set recipe specific attributes.



On Wed, May 29, 2013 at 4:18 PM, Vladimir Skubriev < " target="_blank"> > wrote:
Where i can find chef server ip and hostname in a recipe for add variable to template

For example i have a recipe:

# Creating true /etc/hosts
template "/etc/hosts" do
    mode 0644
    owner "root"
    group "root"
    source "etc/hosts.erb"
    variables ({
                :ip => node[:dc][:ip],
                :domain => node[:dns][:domain],
                :hostname => node[:dc][:hostname],
                :chefserverip => ???????????????,
                :chefserverhostname => ???????????????
                })
    action :create
end


and template:

127.0.0.1           localhost
<%= @chefserverip %>           <%= @chefserverhostname %>.<%= @domain %>
<%= @ip %>        <%= @hostname %>.<%= @domain %> <%= @hostname %>
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

How I can access service variables ??????????????? and ???????????????

And for a future:

How can i know what service vars are present when recipes are run? My be present a simple method or you hac a true doc url ?

Thank you very much.
-- 
Best regards,

CVision Lab System Administrator
Vladmir Skubriev




Archive powered by MHonArc 2.6.16.

§