FAQ
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 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/-/Dx7Ue8P-yx4J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Ramin K at Nov 1, 2012 at 8:38 pm

    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.

    node /^node\d+\.yourdomain\.com$/ {

    include $::osfamily # or the more specific $::operatingsystem
    }

    However if you were to build a case around the node name you can use
    $::hostname or $::clientcert. I use clientcert more often because the
    hostname is not always correct through provisioning in my system. Same
    syntax either way.

    node /^fe\d+\.(ord|lax|sfo)\.mydomain\.com/ inherits basenode {

    include hostgroup::frontend

    case $::clientcert {
    /^fe02(.*)/: { # matching any server named fe02
    cron::listings { 'listings':
    cron_env => 'production_migrate',
    cron_user => 'deploy',
    }
    }
    default: {}
    }

    }

    Ramin

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

    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 puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedNov 1, '12 at 7:13p
activeNov 2, '12 at 1:58p
posts3
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase