Using puppetdbquery (https://github.com/dalen/puppet-puppetdbquery), you could 
do something like this in your manifests -

$hosts = query_nodes('Class[memcached]', hostname)

And then loop through this in your template -

<% @hosts.sort.each do |host| -%><%= host %>:<%= @memcached_port %> <% end -%>

Matt

On Aug 13, 2014, at 9:26 AM, Andrew Melo <andrew.m...@gmail.com> wrote:

> Hello, all-
> 
> I've been (unsuccessfully) looking for/thinking of a solution to the 
> following problem and am unsuccessful, so I figured I'd ask here.
> 
> If you have a service that's across multiple hosts (say, memcached or a 
> mysql/galera HA cluster) where each node needs to know the hostnames of the 
> other nodes in that service, is there another way to implement this in puppet 
> other than first applying the role to each node in the service and then 
> having a list of hostnames stored as a variable in hiera? I'm new to puppet, 
> so I'm unsure if there's a better practice than having to hardcode the hiera 
> part.
> 
> Cheers,
> Andrew
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/085ebdb1-3780-42c7-bc53-ebe682ca8984%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/5878F4E6-60A3-4FAC-80B9-B1F82C465685%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to