to "/etc/ssl/private/ssl-cert-snakeoil.key"
end
- restore_command = settings[:restore_command] || defaults[:restore_command]
standby_mode = settings[:standby_mode] || defaults[:standby_mode]
+ primary_conninfo = settings[:primary_conninfo] || defaults[:primary_conninfo]
+ restore_command = settings[:restore_command] || defaults[:restore_command]
if restore_command || standby_mode == "on"
+ passwords = if primary_conninfo
+ data_bag_item(primary_conninfo[:passwords][:bag],
+ primary_conninfo[:passwords][:item])
+ end
+
template "/var/lib/postgresql/#{version}/main/recovery.conf" do
source "recovery.conf.erb"
owner "postgres"
group "postgres"
mode 0640
- variables :defaults => defaults, :settings => settings
+ variables :standby_mode => standby_mode,
+ :primary_conninfo => primary_conninfo,
+ :restore_command => restore_command,
+ :passwords => passwords
notifies :reload, "service[postgresql]"
end
else
# DO NOT EDIT - This file is being maintained by Chef
-standby_mode = <%= @settings[:standby_mode] || @defaults[:standby_mode] %>
-<% if @settings[:primary_conninfo] || @defaults[:primary_conninfo] -%>
-primary_conninfo = '<%= @settings[:primary_conninfo] || @defaults[:primary_conninfo] %>'
+standby_mode = <%= @standby_mode %>
+<% if @primary_conninfo -%>
+primary_conninfo = 'host=<%= @primary_conninfo[:host] %> port=<%= @primary_conninfo[:port] %> user=<%= @primary_conninfo[:user] %> password=<%= @passwords[@primary_conninfo[:user]] %>'
<% end -%>
-<% if @settings[:restore_command] || @defaults[:restore_command] -%>
-restore_command = '<%= @settings[:restore_command] || @defaults[:restore_command] %>'
+<% if @restore_command -%>
+restore_command = '<%= @restore_command %>'
<% end -%>
--- /dev/null
+name "db-slave"
+description "Role applied to all slave database servers"
+
+default_attributes(
+ :postgresql => {
+ :versions => ["9.1"],
+ :settings => {
+ :defaults => {
+ :hot_standby => "on",
+ :hot_standby_feedback => "on",
+ :standby_mode => "on",
+ :primary_conninfo => {
+ :host => "katla",
+ :port => "5432",
+ :user => "replication",
+ :passwords => { :bag => "db", :item => "passwords" }
+ },
+ :restore_command => "/usr/bin/rsync katla::archive/%f %p"
+ }
+ }
+ }
+)
+
+run_list(
+ "role[db]",
+ "recipe[db::slave]"
+)
--- /dev/null
+name "nominatim-slave"
+description "Role applied to all slave nominatim servers"
+
+default_attributes(
+ :postgresql => {
+ :versions => ["9.3"],
+ :settings => {
+ :defaults => {
+ :hot_standby => "on",
+ :hot_standby_feedback => "on",
+ :standby_mode => "on",
+ :primary_conninfo => {
+ :host => "pummelzacken.ucl.openstreetmap.org",
+ :port => "5432",
+ :user => "replication",
+ :passwords => { :bag => "nominatim", :item => "passwords" }
+ },
+ :restore_command => "/usr/bin/rsync pummelzacken.ucl.openstreetmap.org::archive/%f %p"
+ }
+ }
+ },
+ :nominatim => {
+ :enable_backup => false
+ }
+
+)
+
+run_list(
+ "role[nominatim]",
+ "recipe[nominatim::slave]"
+)