Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

puppet node hostname

I'm using puppet to configure servers. I want to print current machine (node) name in *.erb template. There is hostname variable, but this holds puppetmaster hostname. Is there any good reference/list regarding to this topic?

like image 206
Michal Bryxí Avatar asked Dec 13 '10 11:12

Michal Bryxí


People also ask

What is the server name in Puppet?

The Puppet Server service name is puppetserver . To start and stop the service, use commands such as service puppetserver restart , service puppetserver status for your OS.

What are nodes in Puppet?

A node definition, also known as a node statement, is a block of Puppet code that is included only in matching nodes' catalogs. This allows you to assign specific configurations to specific nodes. Put node definitions in the main manifest, which can be a single site. pp file, or a directory containing many files.

Where is Puppet Conf located?

The puppet. conf file is always located at $confdir/puppet. conf . Although its location is configurable with the config setting, it can be set only on the command line.

What is site PP in Puppet?

The Puppet site manifest (site. pp) is the main file that Puppet uses to define global system configuration.


4 Answers

Seems like I have miss-looked somewhere. I can get(print) node-hostname simply by invoking following code in *.erb template:

<%= @hostname %>

Edit: As of Puppet 3, using local variables (i.e. hostname is deprecated; Puppet 4 will remove support for them entirely. The recommended way is to use instance variables (prefixed with @. So in this case, @hostname. Source

like image 62
Michal Bryxí Avatar answered Sep 24 '22 13:09

Michal Bryxí


Entering the following command into your terminal will return variables available in your erb files:

facter --puppet
like image 44
pcting Avatar answered Sep 25 '22 13:09

pcting


Yes to all the above; you may also find the fqdn variable useful, depending on what you're up to.

If you DO find yourself needing the puppet master server's info in a template, you can use the variables servername, serverip, and serverversion (From the Puppet docs).

like image 6
nfagerlund Avatar answered Sep 26 '22 13:09

nfagerlund


Apparently you can now use

<%= fqdn %> 

and get the DNS reverse name.

If you need to lowercase it, use

<%= fqdn.downcase %>
like image 4
mtneagle Avatar answered Sep 25 '22 13:09

mtneagle