2

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:

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

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

Is this possible?

growse
  • 7,830
  • 11
  • 72
  • 114

1 Answers1

2

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

lsd
  • 1,653
  • 10
  • 8
  • 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 09: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