feat: psql changes on master only #157
11
modules/libs/lib/facter/psql_is_slave.rb
Normal file
11
modules/libs/lib/facter/psql_is_slave.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# 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
|
||||
@ -88,11 +88,14 @@ class profiles::sql::patroni (
|
||||
|
||||
}
|
||||
|
||||
# collect exported resources
|
||||
$tag = "${facts['country']}-${facts['region']}-${facts['environment']}"
|
||||
Profiles::Sql::Postgres::Db <<| tag == $tag |>> {}
|
||||
Profiles::Sql::Postgres::User <<| tag == $tag |>> {}
|
||||
Profiles::Sql::Postgres::Grant <<| tag == $tag |>> {}
|
||||
# only apply changes to DBs/Users/Grants on master
|
||||
if ! $facts['psql_is_slave'] {
|
||||
# collect exported resources
|
||||
$tag = "${facts['country']}-${facts['region']}-${facts['environment']}"
|
||||
Profiles::Sql::Postgres::Db <<| tag == $tag |>> {}
|
||||
Profiles::Sql::Postgres::User <<| tag == $tag |>> {}
|
||||
Profiles::Sql::Postgres::Grant <<| tag == $tag |>> {}
|
||||
}
|
||||
|
||||
if $postgres_exporter_enabled {
|
||||
class { 'prometheus::postgres_exporter':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user