[Puppet Users] List of available variables for use in templates

690 views
Skip to first unread message

Ed Greenberg

unread,
May 5, 2010, 5:07:02 PM5/5/10
to puppet...@googlegroups.com
When writing an ERB template, I know that I can define variables in my
nodes and classes, and that the facter variables for the node are available.

I'd like to know if there are any other predefined puppet variables
available. In specific, I'd like the node's name in the node definition.

node "foobar" {
include this
include that
}

I'd like to get "foobar". In my case, this is probably NOT the facter
variable fqdn or hostname.

I can't find this documented anywhere.

Assistance?

Thanks,
</edg>
Ed Greenberg

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Michael DeHaan

unread,
May 6, 2010, 11:26:53 AM5/6/10
to puppet...@googlegroups.com
On Wed, May 5, 2010 at 5:07 PM, Ed Greenberg <e...@greenberg.org> wrote:
> When writing an ERB template, I know that I can define variables in my nodes
> and classes, and that the facter variables for the node are available.
>
> I'd like to know if there are any other predefined puppet variables
> available. In specific, I'd like the node's name in the node definition.
>
> node "foobar" {
>    include this
>    include that
> }
>
> I'd like to get "foobar".  In my case, this is probably NOT the facter
> variable fqdn or hostname.
>
> I can't find this documented anywhere.

Any particular reason you're not using the node name as the hostname?

Nodes can either use the shortname or the fqdn.

--Michael

Ed Greenberg

unread,
May 6, 2010, 2:04:08 PM5/6/10
to puppet...@googlegroups.com
On 05/06/2010 10:26 AM, Michael DeHaan wrote:
> On Wed, May 5, 2010 at 5:07 PM, Ed Greenberg<e...@greenberg.org> wrote:
>
>> When writing an ERB template, I know that I can define variables in my nodes
>> and classes, and that the facter variables for the node are available.
>>
>> I'd like to know if there are any other predefined puppet variables
>> available. In specific, I'd like the node's name in the node definition.
>>
>> node "foobar" {
>> include this
>> include that
>> }
>>
>> I'd like to get "foobar". In my case, this is probably NOT the facter
>> variable fqdn or hostname.
>>
>> I can't find this documented anywhere.
>>
> Any particular reason you're not using the node name as the hostname?
>
> Nodes can either use the shortname or the fqdn.
>
> --Michael
>
>
These are managed hosting customers. The customer can change hostname at
will. We something that won't change, so we can find the server no
matter what. If I can't find a way to do this, I can visit each host in
the puppet config and stick the node name into a variable, but I was
hoping not to have to do/maintain that.

Question remains open. Does anybody know?

</edg>

Andy Wong

unread,
Nov 7, 2014, 1:34:52 AM11/7/14
to puppet...@googlegroups.com, e...@greenberg.org
https://docs.puppetlabs.com/facter/2.2/core_facts.html#hostname

this is what you want

Ed Greenberg於 2010年5月6日星期四UTC+8上午5時07分02秒寫道:

jcbollinger

unread,
Nov 10, 2014, 9:07:56 AM11/10/14
to puppet...@googlegroups.com, e...@greenberg.org


On Friday, November 7, 2014 12:34:52 AM UTC-6, Andy Wong wrote:


No, actually, it's not.  The string that is used to match nodes to node blocks is the the client's certname, which is available as $clientcert, not (directly) its hostname.  The default configuration of the agent results in these two having the same value, but assuming they will be the same incurs a risk that you simply don't have to take.

 

Ed Greenberg於 2010年5月6日星期四UTC+8上午5時07分02秒寫道:
When writing an ERB template, I know that I can define variables in my
nodes and classes, and that the facter variables for the node are available.

I'd like to know if there are any other predefined puppet variables
available.


Reply all
Reply to author
Forward
0 new messages