puppet-prod/modules/libs/lib/facter/psql_is_slave.rb
Ben Vincent afda425fab feat: psql changes on master only
- add fact to detect if a psql host is a slave
- only import users/db/grants on master
2024-09-03 22:13:50 +10:00

12 lines
369 B
Ruby

# frozen_string_literal: true
Facter.add(:psql_is_slave) do
setcode do
# Command to check if PostgreSQL is in recovery mode
command = 'sudo -iu postgres psql -tAc "select pg_is_in_recovery()"'
# Execute the command and map the output to a boolean value
{ 't' => true, 'f' => false }[Facter::Core::Execution.execute(command, on_fail: nil)]
end
end