Issue #8940 has been updated by Rob Terhaar.

I'd like to be able to manage conditional hosts files based on data center 
location. e.g., for EC2 servers in us-west-1, I'd like to populate a /etc/hosts 
file with private NAT addresses for similar nodes that are also in us-west-1, 
but also populate nodes in us-west-1 with public IP addresses for nodes that 
are in us-east-1. vice versa, 

I'd also like to populate the /etc/hosts files on my Rackspace servers with 
private IPs for other Rackspace nodes, and public IPs for EC2 nodes.

The only way that I can imagine implementing this is to not use Exported 
resources and resort to some ERB hacks, but if I was able to Export multiple 
hosts entries from each server, I could easily realize them conditionally. 


Given the above Export example:
<pre>
  @@host  { "${fqdn}-private":
    canonical_hostname => $fqdn
    host_aliases  => $hostname,
    ip            => $private_ip_interface,
    tag           => "normal_server_private-${region}",
  }

  @@host  { "${fqdn}-public":
    canonical_hostname => $fqdn
    host_aliases  => $hostname,
    ip            => $public_ip_interface,
    tag           => "normal_server_public-${region}",
  }
</pre>

I would build a realize class that would work like:
<pre>
Host <<| tag == normal_server_private-${region} |>>
</pre> 
Which would realize all private IPs in the similar region, but then do
<pre>
Host <<| tag != normal_server_public-${region} |>>
</pre>
To realize public hosts entries on all dissimilar regions. 


I really hope this is clear, and hope that my execution isn't completely 
insane. 
----------------------------------------
Feature #8940: host type should have an optional canonical_hostname parameter
https://projects.puppetlabs.com/issues/8940

Author: Rob Terhaar
Status: Needs More Information
Priority: Normal
Assignee: Nigel Kersten
Category: 
Target version: 
Affected Puppet version: 2.6.8
Keywords: 
Branch: 


If you compare the behavior of the Exec type to the Host type, Exec is more 
flexible because it has a command => parameter. This is useful if you would 
like to create multiple Execs with different namevars, but similar commands. 

When working with the Host type, I've found that the namevar becomes the 
"canonical_hostname", and there is no way to override this. Here's a specific 
example of when having multiple Host resources with the same namevar would be 
useful:

<pre>
  @@host  { "$fqdn":
    host_aliases  => $hostname,
    ip            => $private_ip_interface,
    tag           => "normal_server_private-${region}",
  }

  @@host  { "${fqdn}":
    host_aliases  => $hostname,
    ip            => $public_ip_interface,
    tag           => "normal_server_public-${region}",
  }
</pre>

Since both exported resources have the same namevar, I receive a parse error:
<pre>Error 400 on SERVER: Duplicate definition: Host[puppet.dev.server.com] is 
already defined in file /etc/puppet/modules/hosts/manifests/collect.pp at line 
33; cannot redefine at /etc/puppet/modules/hosts/manifests/collect.pp:43 on 
node puppet.dev.server.com</pre>

However, If the Host type had the ability to pass a canonical hostname (fqdn) 
argument, I could do:
<pre>
  @@host  { "${fqdn}-private":
    canonical_hostname => $fqdn
    host_aliases  => $hostname,
    ip            => $private_ip_interface,
    tag           => "normal_server_private-${region}",
  }

  @@host  { "${fqdn}-public":
    canonical_hostname => $fqdn
    host_aliases  => $hostname,
    ip            => $public_ip_interface,
    tag           => "normal_server_public-${region}",
  }
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" 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-bugs?hl=en.

Reply via email to