On Thursday, November 1, 2012 3:38:38 PM UTC-5, Ramin K wrote:
>
> On 11/1/2012 12:12 PM, romario nguyen wrote:
> > Does any one know how to evaluate a node hostname in the nodes.pp file?
> > for example something like this..
> > node 'node1.com', 'node2.com', 'node3.com' {
> > case node.name {
> > 'node1.com' : { include solaris }
> > 'node2.com' : { include redhat }
> > 'node3.com' : { include aix }
> > default: { include generic }
> > }
> > Much appreciated your feedback. Thanks!
>
> You might consider letting regex and facter do more of the work for you.
>
You don't even need that for the OP's original case. Instead of grouping
nodes and then trying to separate them out again, it would make more sense
to avoid grouping them in the first place:
node 'node1.com' {
include 'solaris'
}
node 'node2.com' {
include 'redhat'
}
node 'node3.com' {
include 'aix'
}
# Note: the default case in the OP's pseudocode
# would never have applied, but I infer that something
# like this was desired:
node default {
include 'generic'
}
On the other hand, in direct answer to the OP's question, nodes.pp is a
Puppet manifest just like any other, so you can access node facts there.
Facts are not dependent on node blocks (and indeed, node blocks are
optional). You can access nodes' hostnames via the $::hostname fact.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/vI4IForuNQ4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.