]> git.openstreetmap.org Git - chef.git/blob - cookbooks/postgresql/templates/default/ohai.rb.erb
overpass: only download sources when missing
[chef.git] / cookbooks / postgresql / templates / default / ohai.rb.erb
1 Ohai.plugin(:Postgresql) do
2   provides "postgresql"
3
4   collect_data(:default) do
5     postgresql Mash.new
6
7     Dir.glob("/etc/postgresql/*/*/postgresql.conf").each do |conf|
8       cluster = conf.sub("/etc/postgresql/", "").sub("/postgresql.conf", "")
9
10       postgresql[:clusters] = Mash.new unless postgresql[:clusters]
11       postgresql[:clusters][cluster] = Mash.new unless postgresql[:clusters][cluster]
12       postgresql[:clusters][cluster][:version] = cluster.split("/").first.to_f
13
14       IO.foreach(conf) do |line|
15         if line =~ /^ *port *= *([0-9]+)\s+/
16           postgresql[:clusters][cluster][:port] = $1
17         end
18       end
19     end
20   end
21 end