On Aug 6, 8:50 am, CraftyTech <hmmed...@gmail.com> wrote:
> So, should the exporting
> of the necessary values be done in the same class as the collection,
> or should I just outline it on my default node definition.  Here's
> what I have so far (and it's not working):

Your example is pretty close. I don't see an obvious reason for it to
fail.

I think you may into two issues in general. Nodes with both
'webserver' & 'mailserver' would export duplicate Host resources. That
gets solved if you move the @@host to a third class and pass
variables, but now you're compile order dependent. Setting
puppetvariables (in manifest) or detecting based on class seems
difficult/unreliable. The best solution for you may be a fact or
variable on your nodes describing which "group" they're part of.

node web {
    $group = ["web"]
    include webserver
    include host::collect
}
node webmail {
    $group = ["web", "mail"]
    include webserver
    include mailserver
    include host::collect
}
class webserver     { include host::export }
class mailserver    { include host::export }
class host::export  { @@host{ "$fqdn": ip => $ipaddress, host_aliases
=> $hostname, tag => $group } }
class host::collect { Host <<| tags == $group |>> }

> Another thing, how do I ensure that the contents of "file" are what
> was collected via the "Host" collection?  If someone has a similar
> scenario running, please share your ideas...

There's no need for the 'file { "/etc/hosts": }' resource. The Host
Type should take care of that. For example 'hosts' may be stored in a
different location or format.

I do it a bit differently. Only nodes with "important" classes export
their entries. All nodes will collect all relevant entries. This
should work as an example.

node dns1 {
    $location = ["chicago"]
    include dns
    include host::collect
}
node ldap1 {
    $location = ["chicago"]
    include ldap
    include host::collect
}
node admin1 {
    $location = ["austin"]
    include dns
    include ldap
    include host::collect
}
node db1 {
    $location = ["austin"]
    include host::collect
}
node db2 {
    $location = ["chicago"]
    include host::collect
}

class dns   { include host::export }
class ldap  { include host::export }
class host::export  { @@host{ "$fqdn": ip => $ipaddress, host_aliases
=> $hostname, tag => $location } }
class host::collect { Host <<| tags == $location |>> }

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

Reply via email to