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?


You might be able to use puppetdbquery, if you are using puppetdb: https://github.com/dalen/puppet-puppetdbquery

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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