X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/2ec62d46e6d050fe6384df90a2869036662d1b51..faf8ae12e85eabb050b0f5eceb2cb67ad1de5261:/cookbooks/postgresql/templates/default/ohai.rb.erb diff --git a/cookbooks/postgresql/templates/default/ohai.rb.erb b/cookbooks/postgresql/templates/default/ohai.rb.erb new file mode 100644 index 000000000..e3eca3a35 --- /dev/null +++ b/cookbooks/postgresql/templates/default/ohai.rb.erb @@ -0,0 +1,17 @@ +provides "postgresql" + +postgresql Mash.new + +Dir.glob("/etc/postgresql/*/*/postgresql.conf").each do |conf| + cluster = conf.sub("/etc/postgresql/", "").sub("/postgresql.conf", "") + + postgresql[:clusters] = Mash.new unless postgresql[:clusters] + postgresql[:clusters][cluster] = Mash.new unless postgresql[:clusters][cluster] + postgresql[:clusters][cluster][:version] = cluster.split("/").first.to_f + + IO.foreach(conf) do |line| + if line =~ /^ *port *= *([0-9]+)\s+/ + postgresql[:clusters][cluster][:port] = $1 + end + end +end