Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions hooks/boot/01-kafo-hook-extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def ensure_packages(packages, state = 'installed')
end
end

def ensure_dnf_module(dnf_module, version)
code = "package { ['#{dnf_module}']: ensure => #{version}, enable_only => true, provider => 'dnfmodule' }"
logger.info("Ensuring #{dnf_module}:#{version} is enabled")
stdout, stderr, status = apply_puppet_code(code)

unless [0, 2].include?(status.exitstatus)
log_and_say(:error, "Failed to ensure #{dnf_module}:#{version} is enabled")
log_and_say(:error, stderr.strip) if stderr && stderr.strip
logger.debug(stdout.strip) if stdout && stdout.strip
logger.debug("Exit status is #{status.exitstatus.inspect}")
exit(1)
end
end

def apply_puppet_code(code)
bin_path = Kafo::PuppetCommand.search_puppet_path('puppet')
Open3.capture3(*Kafo::PuppetCommand.format_command("echo \"#{code}\" | #{bin_path} apply --detailed-exitcodes"))
Expand Down Expand Up @@ -93,6 +107,10 @@ def el7?
facts[:os][:release][:major] == '7' && facts[:os][:family] == 'RedHat'
end

def el8?
facts[:os][:release][:major] == '8' && facts[:os][:family] == 'RedHat'
end

def log_and_say(level, message, do_say = true, do_log = true)
style = case level
when :error
Expand Down
7 changes: 7 additions & 0 deletions hooks/pre/40-el8_modules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (module_enabled?('katello') || module_enabled?('foreman_proxy_content')) && el8?
ensure_dnf_module('pki-core', 'present')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with theforeman/puppet-candlepin#175. We've observed that starting Puppet typically adds a few seconds so I'd prefer to solve it as part of the main loop.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blocks Katello so we need to get any changes and release ASAP.


if local_postgresql?
ensure_dnf_module('postgresql', '12')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take a look at if we can solve this in puppetlabs-postgresql as a long term solution.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be nice there long term, I dont see modules going away.

end
end