Duplicate resource problem for localhost

72 views
Skip to first unread message

Karen Loomans

unread,
Nov 16, 2011, 1:19:43 AM11/16/11
to puppet...@googlegroups.com
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

Nan Liu

unread,
Nov 16, 2011, 5:09:50 PM11/16/11
to puppet...@googlegroups.com

Would this work for your usage:

host { 'ip6-localhost':
ip => '::1',
host_aliases => 'localhost',
}
host { 'localhost':
ip => '127.0.0.1'
}

Thanks,

Nan

Karen Loomans

unread,
Nov 16, 2011, 5:40:02 PM11/16/11
to puppet...@googlegroups.com
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


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


Reply all
Reply to author
Forward
0 new messages