Skip to content

Commit

Permalink
Fixes #30507: Use enabled hook helpers for Katello and Foreman
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Aug 19, 2020
1 parent 115a557 commit c6d28ec
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion hooks/boot/01-kafo-hook-extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def local_foreman_db?
end

def local_candlepin_db?
module_enabled?('katello') && param_value('katello', 'candlepin_manage_db')
candlepin_enabled? && param_value('katello', 'candlepin_manage_db')
end

def local_postgresql?
Expand All @@ -69,6 +69,10 @@ def local_redis?
(foreman_server? && !param_value('foreman', 'jobs_sidekiq_redis_url')) || pulpcore_enabled? || devel_scenario?
end

def candlepin_enabled?
katello_enabled?
end

def pulp_enabled?
module_enabled?('foreman_proxy_plugin_pulp') && (param_value('foreman_proxy_plugin_pulp', 'pulpnode_enabled') || param_value('foreman_proxy_plugin_pulp', 'enabled'))
end
Expand Down
4 changes: 2 additions & 2 deletions hooks/post/99-post_install_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
new_install_message(@kafo) if new_install?
end

if module_enabled?('katello')
if katello_enabled?
certs_generate_command_message
end

if module_enabled?('katello_devel')
if devel_scenario?
dev_server_success_message(@kafo)
dev_new_install_message(@kafo) if new_install?
end
Expand Down
2 changes: 1 addition & 1 deletion hooks/pre/10-reset_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def reset
stop_services
start_services(['postgresql']) if local_postgresql?
empty_db_in_postgresql('foreman') if foreman_server?
reset_candlepin if module_enabled?('katello')
reset_candlepin if candlepin_enabled?
reset_pulp if pulp_enabled?
empty_db_in_postgresql('pulpcore') if pulpcore_enabled?
end
Expand Down
2 changes: 1 addition & 1 deletion katello/hooks/boot/13-hiera.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if module_enabled?('foreman')
if foreman_server?
# TODO: automatically get the tuning sizes - standard doesn't exist and only
# loads base. The rest maps to config/foreman.hiera/tuning/sizes/$size.yaml
TUNING_SIZES = ['default'] + ['medium', 'large', 'extra-large', 'extra-extra-large']
Expand Down
2 changes: 1 addition & 1 deletion katello/hooks/post/31-cdn_setting.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if !app_value(:noop) && module_enabled?('katello')
if !app_value(:noop) && katello_enabled?
param = get_custom_config('cdn_ssl_version')
if param
logger.info 'cdn_ssl_version param found, migrating to a Katello setting'
Expand Down
2 changes: 1 addition & 1 deletion katello/hooks/pre/15-check_java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def error_exit(message, code)
kafo.class.exit code
end

if module_enabled?('katello')
if candlepin_enabled?
java_version_string = `/usr/bin/java -version 2>&1`
java_version = java_version_string.split("\n")[0].split('"')[1]

Expand Down
2 changes: 1 addition & 1 deletion katello/hooks/pre/20-certs_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def mark_for_update(cert_name, hostname = nil)
cert_file = param('certs', 'server_cert').value
key_file = param('certs', 'server_key').value

if app_value('certs_update_server_ca') && !module_enabled?('katello')
if app_value('certs_update_server_ca') && !katello_enabled?
fail_and_exit("--certs-update-server-ca needs to be used with katello", 101)
end

Expand Down
2 changes: 1 addition & 1 deletion katello/hooks/pre_commit/13-hiera.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

current_tuning = get_custom_fact(TUNING_FACT)
if module_enabled?('foreman')
if foreman_server?
new_tuning = app_value(:tuning)
else
new_tuning = current_tuning
Expand Down
3 changes: 1 addition & 2 deletions katello/hooks/pre_commit/14-cdn_setting.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if module_enabled?('katello') &&
@kafo.config.answers['katello'].is_a?(Hash) &&
if @kafo.config.answers['katello'].is_a?(Hash) &&
@kafo.config.answers['katello'].key?('cdn_ssl_version')
# Using @kafo.config.answers because param() goes through PuppetModule. At
# this point the parameter doesn't exist in the module on disk so param()
Expand Down

0 comments on commit c6d28ec

Please sign in to comment.