Managing multiple hosts in a single service

23 views
Skip to first unread message

Andrew Melo

unread,
Aug 13, 2014, 12:26:29 PM8/13/14
to puppet...@googlegroups.com
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

Matthew Schmitt

unread,
Aug 14, 2014, 6:45:07 PM8/14/14
to puppet...@googlegroups.com
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

--
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...@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.

Betsy Schwartz

unread,
Aug 14, 2014, 7:22:16 PM8/14/14
to puppet...@googlegroups.com
The Puppet Practitioner course talks about this. Look at "exported resources" and "exported resource collectors"

Each node exports the resource then can collect the set ( probably , by doubt the puppetdb query under the hood)

Andrew Melo

unread,
Aug 15, 2014, 2:34:29 PM8/15/14
to puppet...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages