-
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 #29512: Call foreman-maintain without SCL context
- Loading branch information
Showing
7 changed files
with
59 additions
and
25 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'English' | ||
require 'open3' | ||
|
||
module ForemanMaintainHookContextExtension | ||
def package_lock_feature? | ||
foreman_maintain('packages -h') | ||
end | ||
|
||
def packages_locked? | ||
foreman_maintain('packages is-locked --assumeyes') | ||
end | ||
|
||
def lock_packages | ||
foreman_maintain('packages lock --assumeyes', true) | ||
end | ||
|
||
def unlock_packages | ||
foreman_maintain('packages unlock --assumeyes', true) | ||
end | ||
|
||
def start_services(services) | ||
foreman_maintain("service start --only=#{services.join(',')}", true) | ||
end | ||
|
||
def stop_services(services) | ||
command = "service stop" | ||
command = "service stop --only=#{services.join(',')}" if services | ||
|
||
foreman_maintain(command, true) | ||
end | ||
|
||
def foreman_maintain(command, exit_on_fail = false) | ||
command = "foreman-maintain #{command}" | ||
log_and_say :debug, "Executing: #{command}" | ||
|
||
_stdout, stderr, status = Open3.capture3(*Kafo::PuppetCommand.format_command(command)) | ||
|
||
fail_and_exit(stderr) if exit_on_fail && !status.success? | ||
status.success? | ||
end | ||
end | ||
|
||
Kafo::HookContext.send(:include, ForemanMaintainHookContextExtension) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if get_custom_config(:lock_package_versions) | ||
log_and_say :info, "Package versions are being locked." | ||
execute('foreman-maintain packages lock --assumeyes', false) | ||
lock_packages | ||
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
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
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