From 43131897893fd6115980b0aeac5e594338c934d1 Mon Sep 17 00:00:00 2001 From: Sean O'Keeffe Date: Wed, 31 Aug 2016 15:18:48 +0100 Subject: [PATCH] Fixes #16388 - rpm -e katello-ca-consumer rpm should revert rhsm.conf --- lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb | 5 +++++ lib/puppet/type/certs_bootstrap_rpm.rb | 2 ++ manifests/katello.pp | 1 + 3 files changed, 8 insertions(+) diff --git a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb index 2fc2675f..931ece51 100644 --- a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb +++ b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb @@ -8,6 +8,9 @@ def run post_script_file = File.join(resource[:dir], 'rhsm-katello-reconfigure') File.open(post_script_file, 'w') { |f| f << resource[:bootstrap_script] } + postun_script_file = File.join(resource[:dir], 'rhsm-katello-remove-reconfigure') + File.open(postun_script_file, 'w') { |f| f << resource[:postun_script] } + Dir.chdir(resource[:dir]) do katello_certs_gen_rpm('--name', resource[:name], '--version', '1.0', @@ -19,6 +22,7 @@ def run '--description', resource[:description], '--requires', 'subscription-manager', '--post', post_script_file, + '--postun', postun_script_file, *resource[:files]) if (rpm = last_rpm) && resource[:alias] File.delete(resource[:alias]) if File.exists?(resource[:alias]) @@ -28,6 +32,7 @@ def run end ensure File.delete(post_script_file) if File.exists?(post_script_file) + File.delete(postun_script_file) if File.exists?(postun_script_file) end protected diff --git a/lib/puppet/type/certs_bootstrap_rpm.rb b/lib/puppet/type/certs_bootstrap_rpm.rb index b0fa5e29..4d1f6310 100644 --- a/lib/puppet/type/certs_bootstrap_rpm.rb +++ b/lib/puppet/type/certs_bootstrap_rpm.rb @@ -23,6 +23,8 @@ newparam(:bootstrap_script) + newparam(:postun_script) + newparam(:files) newparam(:alias) diff --git a/manifests/katello.pp b/manifests/katello.pp index 2bff001c..458898b5 100644 --- a/manifests/katello.pp +++ b/manifests/katello.pp @@ -53,6 +53,7 @@ # (especially in the custom certs scenario) files => ["${katello_rhsm_setup_script_location}:755=${katello_www_pub_dir}/${katello_rhsm_setup_script}"], bootstrap_script => inline_template('/bin/bash <%= @katello_rhsm_setup_script_location %>'), + postun_script => 'test -f /etc/rhsm/rhsm.conf.kat-backup && command cp /etc/rhsm/rhsm.conf.kat-backup /etc/rhsm/rhsm.conf', alias => $candlepin_cert_rpm_alias, subscribe => $::certs::server_ca, }