Karen Loomans
2011-Nov-16 06:19 UTC
[Puppet Users] Duplicate resource problem for localhost
Hi, I have a module to manage /etc/hosts that works fine for RHEL, but not on Solaris. Basically I''ve defined all our hosts as virtual host resources, and grouped them various ways by tagging them. These are then realized based on the tags for each node as appropriate. Hosts can have multiple tags and not have any issues with duplicate resource declarations as they are virtual. Any unmanaged host is then purged from the hosts file. The problem for Solaris occurs with the localhost entries: ::1 localhost 127.0.0.1 localhost You can''t define host resources with the same name. I would prefer to keep using the host resource if I can as it all works beautifully on our RHEL servers (the localhost names are unique). I thought I might be able to: 1. Template the beginning of the hosts file to include the localhost entries appropriate to the os, writing out to /tmp/hosts_head. 2. Generate another file in /tmp/hosts_body that contains the remainder of the hosts using my current method of realizing the virtual hosts. 3. Concatenate the two. However, when I redirect the target for all the host resources to /tmp/hosts_body, it rips out the contents in the real /etc/inet/hosts: notice: /Stage[after]/Hosts::Virtual/Host[george]/target: target changed ''/etc/inet/hosts'' to ''/tmp/hosts_body'' Has anyone solved this problem on Solaris or can offer some suggestions? Thanks in advance, Karen -- 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 Wed, Nov 16, 2011 at 1:19 AM, Karen Loomans <karen@loomans.org> wrote:> Hi, > > I have a module to manage /etc/hosts that works fine for RHEL, but not on > Solaris. Basically I''ve defined all our hosts as virtual host resources, > and grouped them various ways by tagging them. These are then realized > based on the tags for each node as appropriate. Hosts can have multiple > tags and not have any issues with duplicate resource declarations as they > are virtual. Any unmanaged host is then purged from the hosts file. > > The problem for Solaris occurs with the localhost entries: > > ::1 localhost > 127.0.0.1 localhost > > You can''t define host resources with the same name. > > I would prefer to keep using the host resource if I can as it all works > beautifully on our RHEL servers (the localhost names are unique). I thought > I might be able to: > 1. Template the beginning of the hosts file to include the localhost > entries appropriate to the os, writing out to /tmp/hosts_head. > 2. Generate another file in /tmp/hosts_body that contains the remainder > of the hosts using my current method of realizing the virtual hosts. > 3. Concatenate the two. > > However, when I redirect the target for all the host resources to > /tmp/hosts_body, it rips out the contents in the real /etc/inet/hosts: > notice: /Stage[after]/Hosts::Virtual/Host[george]/target: target changed > ''/etc/inet/hosts'' to ''/tmp/hosts_body'' > > Has anyone solved this problem on Solaris or can offer some suggestions?Would this work for your usage: host { ''ip6-localhost'': ip => ''::1'', host_aliases => ''localhost'', } host { ''localhost'': ip => ''127.0.0.1'' } Thanks, Nan -- 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.
Karen Loomans
2011-Nov-16 22:40 UTC
Re: [Puppet Users] Duplicate resource problem for localhost
Hi Nan, Thanks for the reply. That was the first thing I asked our group, but unfortunately for the Solaris servers it is the group''s policy not to alias localhost (for various reasons I won''t go into here). I''ll raise it again, but if an alternate solution can be found it would be preferable. Any other ideas? Cheers, Karen On Thu, Nov 17, 2011 at 8:09 AM, Nan Liu <nan@puppetlabs.com> wrote:> On Wed, Nov 16, 2011 at 1:19 AM, Karen Loomans <karen@loomans.org> wrote: > > Hi, > > > > I have a module to manage /etc/hosts that works fine for RHEL, but not on > > Solaris. Basically I''ve defined all our hosts as virtual host resources, > > and grouped them various ways by tagging them. These are then realized > > based on the tags for each node as appropriate. Hosts can have multiple > > tags and not have any issues with duplicate resource declarations as they > > are virtual. Any unmanaged host is then purged from the hosts file. > > > > The problem for Solaris occurs with the localhost entries: > > > > ::1 localhost > > 127.0.0.1 localhost > > > > You can''t define host resources with the same name. > > > > I would prefer to keep using the host resource if I can as it all works > > beautifully on our RHEL servers (the localhost names are unique). I > thought > > I might be able to: > > 1. Template the beginning of the hosts file to include the localhost > > entries appropriate to the os, writing out to /tmp/hosts_head. > > 2. Generate another file in /tmp/hosts_body that contains the > remainder > > of the hosts using my current method of realizing the virtual hosts. > > 3. Concatenate the two. > > > > However, when I redirect the target for all the host resources to > > /tmp/hosts_body, it rips out the contents in the real /etc/inet/hosts: > > notice: /Stage[after]/Hosts::Virtual/Host[george]/target: target > changed > > ''/etc/inet/hosts'' to ''/tmp/hosts_body'' > > > > Has anyone solved this problem on Solaris or can offer some suggestions? > > Would this work for your usage: > > host { ''ip6-localhost'': > ip => ''::1'', > host_aliases => ''localhost'', > } > host { ''localhost'': > ip => ''127.0.0.1'' > } > > Thanks, > > Nan > > -- > 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. > >-- 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.