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.