-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37717 - Update evr extension ownership to foreman
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# In Katello 4.14, the 'evr' extension is removed from PostgreSQL and integrated into the Katello database via a migration. | ||
# This hook ensures the 'evr' extension's ownership is transferred to the 'foreman' user so migrations can act on it. | ||
|
||
if local_postgresql? && execute("rpm -q postgresql-evr", false, false) | ||
is_postgresql_active = execute_command("systemctl is-active postgresql", false, true)&.first&.strip == "active" | ||
|
||
# Ensure the PostgreSQL service is running | ||
unless is_postgresql_active || app_value(:noop) | ||
logger.debug("Starting postgresql service") | ||
start_services(['postgresql']) | ||
end | ||
|
||
# Update the ownership of the evr extension | ||
unless app_value(:noop) | ||
logger.debug("Updating ownership of the evr extension if it is enabled") | ||
execute!("runuser -l postgres -c \"psql -d foreman -c \\\"UPDATE pg_extension SET extowner = (SELECT oid FROM pg_authid WHERE rolname='foreman') WHERE extname='evr';\\\"\"", false, true) | ||
end | ||
|
||
# Stop the PostgreSQL service if it was not running | ||
unless is_postgresql_active || app_value(:noop) | ||
logger.debug("Stopping postgresql service") | ||
stop_services(['postgresql']) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters