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''|>> } } -- 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.
On Feb 3, 3:24 pm, chris mague <christianma...@gmail.com> 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 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.
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 <John.Bollin...@stJude.org> wrote:> On Feb 3, 3:24 pm, chris mague <christianma...@gmail.com> 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 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.
On Feb 4, 11:01 am, chris mague <christianma...@gmail.com> wrote:> 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 [...]> I think this would be possible in 2.6.4 by doing > > Host <<| tag == "stagehosts" and title != $fqdn |>>Ah. That does make more sense. Are you using tags to distinguish between different groups of exported hosts? If not, then I think you should be able to do this: ===Host { target => ''/etc/hosts'' } @@host { $fqdn: ip => $ipaddress, host_aliases => [$hostname], } Host <<| name != $fqdn |>> host { "localhost.localdomain": ip => ''127.0.0.1'', host_aliases => [ ''localhost'', ''foo.bar.com'', ''foo'' ] } resources { "host": purge => true } === If that doesn''t meet your need then you may need to consider upgrading Puppet. However, I don''t see any closed tickets that lead me to expect a change between 2.6.2 and 2.6.4 with respect to filter conditions, nor any open ones leading me to believe that 2.6.2 doesn''t already handle logical combinations of filter criteria as documented. Do you get an error when you try? If it''s broken, you should file a ticket so that it gets fixed. Any way around, you should probably filter on ''name'' as I do above, not on ''title''. The name should be what actually gets written into the hosts file; title can conceivably be something different. The bottom line is this: to collect some but not all exported resources of a given type, you have to provide filter conditions that distinguish between the resources you want and those you don''t. Best, John -- 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.
Reasonably Related Threads
- Help on a Nat To Nat soluction - tinc servers won't ping remote clients
- Route certain trafic via a tinc node that is not directly connected.
- HOWTO (advanced) ssh transparent proxy jump
- Option to turn off listen port, e.g. client only mode
- Agent Forwarding Anomalies on OpenBSD 3.3/OpenSSH 3.6.1