# limitations under the License.
#
-if File.exists?("/etc/init.d/postgresql")
- service "postgresql" do
- action [ :enable, :start ]
- supports :status => true, :restart => true, :reload => true
- end
+package "postgresql-common"
+
+service "postgresql" do
+ action [:enable, :start]
+ supports :status => true, :restart => true, :reload => true
end
node[:postgresql][:versions].each do |version|
package "postgresql-contrib-#{version}"
package "postgresql-server-dev-#{version}"
- if File.exists?("/etc/init.d/postgresql-#{version}")
- service "postgresql-#{version}" do
- action [ :enable, :start ]
- supports :status => true, :restart => true, :reload => true
- end
- end
-
defaults = node[:postgresql][:settings][:defaults] || {}
settings = node[:postgresql][:settings][version] || {}
group "postgres"
mode 0644
variables :version => version, :defaults => defaults, :settings => settings
- if File.exists?("/etc/init.d/postgresql-#{version}")
- notifies :reload, resources(:service => "postgresql-#{version}")
- else
- notifies :reload, resources(:service => "postgresql")
- end
+ notifies :reload, "service[postgresql]"
end
template "/etc/postgresql/#{version}/main/pg_hba.conf" do
mode 0640
variables :early_rules => settings[:early_authentication_rules] || defaults[:early_authentication_rules],
:late_rules => settings[:late_authentication_rules] || defaults[:late_authentication_rules]
- if File.exists?("/etc/init.d/postgresql-#{version}")
- notifies :reload, resources(:service => "postgresql-#{version}")
- else
- notifies :reload, resources(:service => "postgresql")
- end
+ notifies :reload, "service[postgresql]"
end
template "/etc/postgresql/#{version}/main/pg_ident.conf" do
group "postgres"
mode 0640
variables :maps => settings[:user_name_maps] || defaults[:user_name_maps]
- if File.exists?("/etc/init.d/postgresql-#{version}")
- notifies :reload, resources(:service => "postgresql-#{version}")
- else
- notifies :reload, resources(:service => "postgresql")
- end
+ notifies :reload, "service[postgresql]"
end
link "/var/lib/postgresql/#{version}/main/server.crt" do
group "postgres"
mode 0640
variables :defaults => defaults, :settings => settings
- if File.exists?("/etc/init.d/postgresql-#{version}")
- notifies :reload, resources(:service => "postgresql-#{version}")
- else
- notifies :reload, resources(:service => "postgresql")
- end
+ notifies :reload, "service[postgresql]"
end
else
template "/var/lib/postgresql/#{version}/main/recovery.conf" do
action :delete
- if File.exists?("/etc/init.d/postgresql-#{version}")
- notifies :reload, resources(:service => "postgresql-#{version}")
- else
- notifies :reload, resources(:service => "postgresql")
- end
+ notifies :reload, "service[postgresql]"
end
end
end
clusters = node[:postgresql][:clusters] || []
-clusters.each do |name,details|
+clusters.each do |name, details|
suffix = name.tr("/", ":")
munin_plugin "postgres_bgwriter_#{suffix}" do
conf_variables :port => details[:port]
end
- if File.exist?("/var/lib/postgresql/#{details[:version]}/main/recovery.conf")
- munin_plugin "postgres_replication_#{suffix}" do
- target "postgres_replication"
- conf "munin.erb"
- conf_variables :port => details[:port]
- end
+ next unless File.exist?("/var/lib/postgresql/#{details[:version]}/main/recovery.conf")
+
+ munin_plugin "postgres_replication_#{suffix}" do
+ target "postgres_replication"
+ conf "munin.erb"
+ conf_variables :port => details[:port]
end
end