#
# Cookbook:: kosmos_postgresql
# Recipe:: primary
#

postgresql_version = "12"
postgresql_service = "postgresql@#{postgresql_version}-main"

service postgresql_service do
  supports restart: true, status: true, reload: true
end

postgresql_custom_server postgresql_version do
  role "primary"
end

postgresql_access "zerotier members" do
  access_type "host"
  access_db "all"
  access_user "all"
  access_addr "10.1.1.0/24"
  access_method "md5"
  notifies :reload, "service[#{postgresql_service}]", :immediately
end

postgresql_access "zerotier members replication" do
  access_type "host"
  access_db "replication"
  access_user "replication"
  access_addr "10.1.1.0/24"
  access_method "md5"
  notifies :reload, "service[#{postgresql_service}]", :immediately
end
