John, Thanks for the hint. It was unclear what I wanted to do.
Instead of excluding one host from the exported resources, I would like to autopopulate /etc/hosts, overriding the value stored in the database for the host itself like follows: hosta => /etc/hosts 127.0.0.1 hosta.foo.com hosta 1.2.3.4 hostb.foo.com hostb 2.3.4.5 hostc.foo.com hostc hostb => /etc/hosts 4.5.6.7 hosta.foo.com hosta 127.0.0.1 hostb.foo.com hostb 2.3.4.5 hostc.foo.com hostc hostc => /etc/hosts 4.5.6.7 hosta.foo.com hosta 1.2.3.4 hostb.foo.com hostb 127.0.0.1 hostc.foo.com hostc I think this would be possible in 2.6.4 by doing Host <<| tag == "stagehosts" and title != $fqdn |>> but I'm on 2.6.2 -c On Feb 4, 7:22 am, jcbollinger <[email protected]> wrote: > On Feb 3, 3:24 pm, chris mague <[email protected]> wrote: > > > > > I have the class below to export host entries. > > However I wish to override the entry for my host to 127.0.0.1 > > > So for all of the hosts other than foo.bar.com I would like them to > > have the real IP address but for foo.bar.com I would like to just have > > the loopback host entry. 2.6.2 doesn't allow multiple tags and if I > > put in another entry for localhost there is a collision. > > > Is there any way to accomplish this in 2.6.2? > > > ========================================================= > > class stagehosts { > > > if $MY_CUSTOM_FACT =~ /BLAH-BLAH/ { > > @@host { $fqdn: > > target => '/etc/hosts', > > ip => $ipaddress, > > host_aliases => [$hostname], > > tag => stagehosts, > > } > > Host <<|tag == 'stagehosts'|>> > > } > > It's not entirely clear to me what you want to achieve. I'm > interpreting your description to say that you don't want nodes other > than foo.bar.com to have a hosts entry for foo.bar.com at all, and > that you want foo.bar.com to have 'foo.bar.com' as an alias for > localhost. That seems a bit strange, but how about something like > this: > > ==== > Host { target => '/etc/hosts' } > resources { "host": purge => true } > > if $fqdn != 'foo.bar.com' { > @@host { $fqdn: > ip => $ipaddress, > host_aliases => [$hostname], > tag => stagehosts > } > > } > > host { "localhost.localdomain": > ip => '127.0.0.1', > host_aliases => $fqdn ? { > 'foo.bar.com' => [ 'localhost', 'foo.bar.com', 'foo' ], > default => [ 'localhost' ] > } > > } > > Host <<|tag == 'stagehosts'|>> > ==== > > I haven't tested that, but it looks like it should work. It would > also be possible to give foo.bar.com a normal hosts entry for itself > without exporting it to other nodes, and/or to have other nodes > declare 'foo.bar.com' as an alias for localhost. > > I left out your condition on a custom fact, as I'm not sure how it's > supposed to fit into the picture, but I trust you can re-insert it in > an appropriate manner. > > Also, do not overlook the "resources" resource I added: this should > cause hosts entries to be removed from a given node if they are not > among those that you are managing for that node. If you don't want > that behavior then remove that declaration, but I recommend you keep > it and commit to fully managing the hosts file via Puppet. > > Cheers, > > John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. 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.
