-default[:db][:cluster] = "9.5/main"
+default[:db][:cluster] = "15/main"
-default[:postgresql][:versions] |= ["9.5", "15"]
+default[:postgresql][:versions] |= ["15"]
package "postgresql-#{version}-postgis-3"
end
-if node[:postgresql][:clusters][:"14/main"]
+if node[:postgresql][:clusters][:"15/main"]
postgresql_user "apis" do
- cluster "14/main"
+ cluster "15/main"
end
template "/usr/local/bin/cleanup-rails-assets" do
secret_key_base = persistent_token("dev", "rails", name, "secret_key_base")
postgresql_database database_name do
- cluster "14/main"
+ cluster "15/main"
owner "apis"
end
postgresql_extension "#{database_name}_btree_gist" do
- cluster "14/main"
+ cluster "15/main"
database database_name
extension "btree_gist"
end
group "apis"
repository details[:repository]
revision details[:revision]
- database_port node[:postgresql][:clusters][:"14/main"][:port]
+ database_port node[:postgresql][:clusters][:"15/main"][:port]
database_name database_name
database_username "apis"
email_from "OpenStreetMap <web@noreply.openstreetmap.org>"
group "root"
mode "640"
variables :cgimap_port => cgimap_port,
- :database_port => node[:postgresql][:clusters][:"14/main"][:port],
+ :database_port => node[:postgresql][:clusters][:"15/main"][:port],
:database_name => database_name,
:log_directory => log_directory
end
postgresql_database database_name do
action :drop
- cluster "14/main"
+ cluster "15/main"
end
end
end
defaults = node[:postgresql][:settings][:defaults] || {}
settings = node[:postgresql][:settings][version] || {}
+ standby_mode = settings[:standby_mode] || defaults[:standby_mode]
+ primary_conninfo = settings[:primary_conninfo] || defaults[:primary_conninfo]
+ restore_command = settings[:restore_command] || defaults[:restore_command]
+
+ passwords = if primary_conninfo
+ data_bag_item(primary_conninfo[:passwords][:bag],
+ primary_conninfo[:passwords][:item])
+ end
+
template "/etc/postgresql/#{version}/main/postgresql.conf" do
source "postgresql.conf.erb"
owner "postgres"
group "postgres"
mode "644"
- variables :version => version, :defaults => defaults, :settings => settings
+ variables :version => version,
+ :defaults => defaults,
+ :settings => settings,
+ :primary_conninfo => primary_conninfo,
+ :passwords => passwords
notifies :reload, "service[postgresql]"
only_if { ::Dir.exist?("/etc/postgresql/#{version}/main") }
end
only_if { ::Dir.exist?("/var/lib/postgresql/#{version}/main") }
end
- 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
-
+ if version.to_f < 12 && (restore_command || standby_mode == "on")
template "/var/lib/postgresql/#{version}/main/recovery.conf" do
source "recovery.conf.erb"
owner "postgres"
only_if { ::Dir.exist?("/var/lib/postgresql/#{version}/main") }
end
end
+
+ if version.to_f > 11 && standby_mode == "on"
+ file "/var/lib/postgresql/#{version}/main/standby.signal" do
+ owner "postgres"
+ group "postgres"
+ mode "640"
+ end
+ else
+ file "/var/lib/postgresql/#{version}/main/standby.signal" do
+ action :delete
+ end
+ end
end
service "postgresql" do
"PG_EXPORTER_AUTO_DISCOVER_DATABASES" => "true",
"PG_EXPORTER_EXCLUDE_DATABASES" => "postgres,template0,template1"
restrict_address_families "AF_UNIX"
+ remove_ipc false
subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]"
end
archive_command = '<%= @settings[:archive_command] || @defaults[:archive_command] %>'
<% end -%>
+# - Archive Recovery -
+
+# These are only used in recovery mode.
+
+<% if @settings[:restore_command] || @defaults[:restore_command] -%>
+restore_command = '<%= @settings[:restore_command] || @defaults[:restore_command] %>'
+<% end -%>
+
#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------
# - Standby Servers -
+<% if @primary_conninfo -%>
+primary_conninfo = 'host=<%= @primary_conninfo[:host] %> port=<%= @primary_conninfo[:port] %> user=<%= @primary_conninfo[:user] %> password=<%= @passwords[@primary_conninfo[:user]] %>'
+<% end -%>
hot_standby = <%= @settings[:hot_standby] || @defaults[:hot_standby] %>
hot_standby_feedback = <%= @settings[:hot_standby_feedback] || @defaults[:hot_standby_feedback] %>
# - Query/Index Statistics Collector -
track_activity_query_size = <%= @settings[:track_activity_query_size] || @defaults[:track_activity_query_size] %>
+<% if @version.to_f < 15 -%>
stats_temp_directory = '/run/postgresql/<%= @version %>-main.pg_stat_tmp'
+<% end -%>
#------------------------------------------------------------------------------
# AUTOVACUUM PARAMETERS
subscribes :extract, "remote_file[#{cache_dir}/karma-linux-amd64.tar.gz]"
end
-promscale_version = "0.16.0"
+promscale_version = "0.17.0"
+promscale_extension_version = "0.8.0-1"
database_version = node[:timescaledb][:database_version]
database_cluster = "#{database_version}/main"
promscale-extension-postgresql-#{database_version}
]
+package "promscale-extension-postgresql-#{database_version}" do
+ version promscale_extension_version
+end
+
+apt_preference "promscale-extension-postgresql" do
+ pin "version #{promscale_extension_version}"
+ pin_priority "1100"
+end
+
postgresql_user "prometheus" do
cluster database_cluster
superuser true
property :private_devices, [true, false]
property :protect_clock, [true, false]
property :restrict_address_families, [String, Array]
+property :remove_ipc, [true, false]
property :system_call_filter, [String, Array]
property :service, :kind_of => String
property :scrape_interval, :kind_of => String
private_devices new_resource.private_devices if new_resource.property_is_set?(:private_devices)
protect_clock new_resource.protect_clock if new_resource.property_is_set?(:protect_clock)
restrict_address_families new_resource.restrict_address_families if new_resource.property_is_set?(:restrict_address_families)
+ remove_ipc new_resource.remove_ipc if new_resource.property_is_set?(:remove_ipc)
system_call_filter new_resource.system_call_filter if new_resource.property_is_set?(:system_call_filter)
end
cron
locales-all
systemd-coredump
+ vim
]
service "rsyslog" do
mode "644"
end
-service "rails-jobs@mailers" do
- action [:enable, :start]
- supports :restart => true
- subscribes :restart, "rails_port[www.openstreetmap.org]"
- subscribes :restart, "systemd_service[rails-jobs@]"
-end
+if %w[database_offline database_readonly].include?(node[:web][:status])
+ service "rails-jobs@mailers" do
+ action :stop
+ end
-service "rails-jobs@storage" do
- action [:enable, :start]
- supports :restart => true
- subscribes :restart, "rails_port[www.openstreetmap.org]"
- subscribes :restart, "systemd_service[rails-jobs@]"
-end
+ service "rails-jobs@storage" do
+ action :stop
+ end
+
+ service "rails-jobs@traces" do
+ action :stop
+ end
+else
+ service "rails-jobs@mailers" do
+ action [:enable, :start]
+ supports :restart => true
+ subscribes :restart, "rails_port[www.openstreetmap.org]"
+ subscribes :restart, "systemd_service[rails-jobs@]"
+ end
+
+ service "rails-jobs@storage" do
+ action [:enable, :start]
+ supports :restart => true
+ subscribes :restart, "rails_port[www.openstreetmap.org]"
+ subscribes :restart, "systemd_service[rails-jobs@]"
+ end
-service "rails-jobs@traces" do
- action [:enable, :start]
- supports :restart => true
- subscribes :restart, "rails_port[www.openstreetmap.org]"
- subscribes :restart, "systemd_service[rails-jobs@]"
+ service "rails-jobs@traces" do
+ action [:enable, :start]
+ supports :restart => true
+ subscribes :restart, "rails_port[www.openstreetmap.org]"
+ subscribes :restart, "systemd_service[rails-jobs@]"
+ end
end
:postgresql => {
:settings => {
:defaults => {
- :wal_level => "logical",
:archive_mode => "on",
:archive_command => "/usr/local/bin/openstreetmap-wal-g wal-push %p --walg-prevent-wal-overwrite=true",
- :max_wal_senders => "10",
:max_replication_slots => "1",
:late_authentication_rules => [
{ :database => "replication", :user => "replication", :address => "10.0.0.4/32" }, # snap-02
:listen_addresses => "*",
:max_connections => "1500",
:max_stack_depth => "7MB",
+ :wal_level => "logical",
:checkpoint_segments => "32",
:max_wal_size => "1536MB",
:checkpoint_completion_target => "0.8",
+ :max_wal_senders => "10",
:cpu_tuple_cost => "0.1",
:log_min_duration_statement => "1000",
:late_authentication_rules => [
}
},
:postgresql => {
- :versions => ["14"],
+ :versions => ["15"],
:settings => {
:defaults => {
:max_connections => "500",
:max_stack_depth => "4MB",
:effective_cache_size => "4GB"
},
- "14" => {
+ "15" => {
:port => "5432",
:wal_level => "logical",
:max_replication_slots => "1"
run_list(
"role[ucl]",
- "role[db-master]"
+ "role[db-slave]"
)
# Required by serverspec
set :backend, :exec
-describe package("postgresql-9.5") do
+describe package("postgresql-15") do
it { should be_installed }
end
-describe service("postgresql@9.5-main") do
+describe service("postgresql@15-main") do
it { should be_enabled }
it { should be_running }
end
# Required by serverspec
set :backend, :exec
-describe package("postgresql-9.5") do
+describe package("postgresql-15") do
it { should be_installed }
end
-describe service("postgresql@9.5-main") do
+describe service("postgresql@15-main") do
it { should be_enabled }
it { should be_running }
end
# Required by serverspec
set :backend, :exec
-describe package("postgresql-9.5") do
+describe package("postgresql-15") do
it { should be_installed }
end
-describe service("postgresql@9.5-main") do
+describe service("postgresql@15-main") do
it { should be_enabled }
it { should be_running }
end