Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a puppet module for ocfs2 and making use of exported resources to populate the definitions of all the cluster nodes in the config file on each cluster. This all works well. The cluster class is simply ocfs::cluster and the member class is ocfs::clustermember

However, in the cluster definition in the config file, I need to list the number of nodes that are in the cluster. However, I can't figure out a way of adding the size of the exported resource array into the template.

Essentially, I'd like to be able to do something like this in the template:

    name = <%= clustername %>
    nodecount = <%= clustername %>
    node_count = <%= @ocfs::cluster.length %>

Obviously this doesn't work, because ocfs::cluster isn't an array.

Is this possible?

share|improve this question
up vote 2 down vote accepted

You might be able to use puppetdbquery, if you are using puppetdb:

share|improve this answer
I'm not using puppetdb, but I am storing configs in mysql. Would there be a way of pulling out a simple query from mysql into a puppet variable? – growse Jan 22 '13 at 9:58
This ended up being the right answer. I switched to puppetdb, and could then query the resources by the correct cluster name and exported status into an array, and then count that array. – growse Jan 22 '13 at 10:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.