Skip to content

Commit

Permalink
Fixes #31614: Enable Pulp 3 by default on server and proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Jan 28, 2021
1 parent 9f42905 commit a3d1da7
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 140 deletions.
6 changes: 1 addition & 5 deletions config/foreman-proxy-content-answers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
certs:
generate: false
foreman_proxy_content:
proxy_pulp_isos_to_pulpcore: false
proxy_pulp_yum_to_pulpcore: false
pulpcore_mirror: true
foreman_proxy:
foreman_ssl_ca: /etc/foreman-proxy/foreman_ssl_ca.pem
foreman_ssl_cert: /etc/foreman-proxy/foreman_ssl_cert.pem
Expand All @@ -31,9 +30,6 @@ foreman_proxy::plugin::dhcp::remote_isc: false
foreman_proxy::plugin::discovery: false
foreman_proxy::plugin::dns::infoblox: false
foreman_proxy::plugin::openscap: false
foreman_proxy::plugin::pulp:
enabled: false
pulpnode_enabled: true
foreman_proxy::plugin::remote_execution::ssh: false
puppet:
server: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
answers.delete('foreman_proxy::plugin::pulp')

if answers['foreman_proxy_content'].is_a?(Hash)
answers['foreman_proxy_content']['pulpcore_mirror'] = true

# Prior migrations add these so we need to ensure they are deleted
# config/katello.migrations/200611220455-dont-proxy-pulp-yum-to-pulpcore-on-upgrades.rb
# config/katello.migrations/200123161606-enable-pulpcore.rb
# config/katello.migrations/202011084146-dont-proxy-pulp-deb-to-pulpcore-on-upgrades.rb
answers['foreman_proxy_content'].delete('proxy_pulp_isos_to_pulpcore')
answers['foreman_proxy_content'].delete('proxy_pulp_yum_to_pulpcore')
end
2 changes: 0 additions & 2 deletions config/katello-answers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ foreman_proxy::plugin::discovery: false
foreman_proxy::plugin::dns::infoblox: false
foreman_proxy::plugin::monitoring: false
foreman_proxy::plugin::openscap: false
foreman_proxy::plugin::pulp:
pulpcore_enabled: true
foreman_proxy::plugin::remote_execution::ssh: false
foreman_proxy::plugin::salt: false
foreman_proxy_content:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
answers.delete('foreman_proxy::plugin::pulp')
26 changes: 1 addition & 25 deletions hooks/boot/01-kafo-hook-extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,8 @@ 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

def pulp_present?
module_present?('foreman_proxy_plugin_pulp')
end

def pulpcore_enabled?
module_enabled?('foreman_proxy_plugin_pulp') && param_value('foreman_proxy_plugin_pulp', 'pulpcore_enabled')
module_enabled?('foreman_proxy_content')
end

def needs_postgresql_scl_upgrade?
Expand Down Expand Up @@ -155,22 +147,6 @@ def execute_command(command, do_say, do_log)
def remote_host?(hostname)
!['localhost', '127.0.0.1', `hostname`.strip].include?(hostname)
end

def load_mongo_config
seeds = param_value('katello', 'pulp_db_seeds')
seed = seeds&.split(',')&.first
host, port = seed.split(':') if seed
{
host: host || 'localhost',
port: port || '27017',
database: param_value('katello', 'pulp_db_name') || 'pulp_database',
username: param_value('katello', 'pulp_db_username'),
password: param_value('katello', 'pulp_db_password'),
ssl: param_value('katello', 'pulp_db_ssl') || false,
ca_path: param_value('katello', 'pulp_db_ca_path'),
ssl_certfile: param_value('katello', 'pulp_db_ssl_certfile'),
}
end
end

Kafo::HookContext.send(:include, HookContextExtension)
9 changes: 0 additions & 9 deletions hooks/boot/12-clear_pulp_content.rb

This file was deleted.

28 changes: 0 additions & 28 deletions hooks/pre/10-reset_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def reset
start_services(['postgresql']) if local_postgresql?
empty_db_in_postgresql('foreman') if foreman_server?
reset_candlepin if candlepin_enabled?
reset_pulp if pulp_enabled?
reset_pulpcore if pulpcore_enabled?
end

Expand Down Expand Up @@ -57,33 +56,6 @@ def reset_candlepin
empty_db_in_postgresql('candlepin')
end

def empty_mongo(config)
if config[:ssl]
ssl = '--ssl'
if config[:ca_path]
ca_cert = "--sslCAFile #{config[:ca_path]}"
client_cert = "--sslPEMKeyFile #{config[:ssl_certfile]}" if config[:ssl_certfile]
end
end
username = "-u #{config[:username]}" if config[:username]
password = "-p #{config[:password]}" if config[:password]
host = "--host #{config[:host]} --port #{config[:port]}"
cmd = "mongo #{config[:database]} #{username} #{password} #{host} #{ssl} #{ca_cert} #{client_cert} --eval 'db.dropDatabase();'"
execute!(cmd)
end

def reset_pulp
execute!('rm -f /var/lib/pulp/init.flag')

mongo_config = load_mongo_config
start_services(['rh-mongodb34-mongod']) unless remote_host?(mongo_config[:host])
logger.info 'Dropping Pulp database!'
empty_mongo(mongo_config)

logger.info 'Clearing Pulp content from disk.'
execute!('rm -rf /var/lib/pulp/{distributions,published,repos,content}/*')
end

def pg_command_base(config, command, args)
"PGPASSWORD='#{config[:password]}' #{command} -U #{config[:username]} -h #{config[:host]} -p #{config[:port]} #{args}"
end
Expand Down
47 changes: 0 additions & 47 deletions hooks/pre/12-clear_pulp_content.rb

This file was deleted.

1 change: 0 additions & 1 deletion hooks/pre/32-install_selinux_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
packages << 'katello-selinux' if katello_enabled?
packages << 'candlepin-selinux' if katello_enabled?
packages << 'pulpcore-selinux' if pulpcore_enabled?
packages << 'crane-selinux' if pulp_enabled?

ensure_packages(packages, 'installed')
end
2 changes: 1 addition & 1 deletion hooks/pre_commit/14-mongo-cache-size.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Setting Default Mongo WiredTiger Engine cache size to be 20% of total memory
# See https://access.redhat.com/solutions/4505561
# See https://docs.mongodb.com/manual/core/wiredtiger/#memory-use
if pulp_enabled?
if katello_enabled? || devel_scenario?
MONGO_CACHE_SIZE_FACT = 'mongo_cache_size'.freeze

current_mongo_cache_size = get_custom_fact(MONGO_CACHE_SIZE_FACT)
Expand Down
16 changes: 0 additions & 16 deletions hooks/pre_validations/12-clear_pulp_content.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ foreman_proxy::plugin::chef: false
foreman_proxy::plugin::dhcp::remote_isc: false
foreman_proxy::plugin::discovery: false
foreman_proxy::plugin::monitoring: false
foreman_proxy::plugin::pulp:
pulpcore_enabled: true
foreman_proxy::plugin::salt: false
foreman_proxy_content:
proxy_pulp_deb_to_pulpcore: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ foreman_proxy::plugin::chef: false
foreman_proxy::plugin::dhcp::remote_isc: false
foreman_proxy::plugin::discovery: false
foreman_proxy::plugin::monitoring: false
foreman_proxy::plugin::pulp:
pulpcore_enabled: true
foreman_proxy::plugin::salt: false
foreman_proxy_content:
proxy_pulp_isos_to_pulpcore: false
Expand Down
2 changes: 0 additions & 2 deletions spec/fixtures/pulpcore-migration/katello-answers-after.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ foreman_proxy::plugin::chef: false
foreman_proxy::plugin::dhcp::remote_isc: false
foreman_proxy::plugin::discovery: false
foreman_proxy::plugin::monitoring: false
foreman_proxy::plugin::pulp:
pulpcore_enabled: true
foreman_proxy::plugin::salt: false
foreman_proxy_content:
proxy_pulp_isos_to_pulpcore: false
Expand Down

0 comments on commit a3d1da7

Please sign in to comment.