puppet node hostname
Entering the following command into your terminal will return variables available in your erb files:
facter --puppet
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
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).