summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Barnett <jason.w.barnett@gmail.com>2022-05-17 13:24:55 -0600
committerGitHub <noreply@github.com>2022-05-17 12:24:55 -0700
commit46ccf0d12d07b85c7809d36ab4a1253c3ecc53aa (patch)
tree448be6e9cebbb519b55207ff5e8e0a1780c2d0d9
parent53c2e4992ab729e6eb86c2cb2f81063cf68948b9 (diff)
downloadchef-46ccf0d12d07b85c7809d36ab4a1253c3ecc53aa.tar.gz
flush package cache after registering or unregistering with rhsm_register (#12828)
Signed-off-by: Jason Barnett <jason.w.barnett@gmail.com>
-rw-r--r--lib/chef/resource/rhsm_register.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index 53e1bc8daf..04c8f475bb 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -117,12 +117,17 @@ class Chef
end
end
+ package flush_package_cache_name do
+ action :nothing
+ end
+
execute "Register to RHSM" do
sensitive new_resource.sensitive
command register_command
default_env true
action :run
not_if { registered_with_rhsm? } unless new_resource.force
+ notifies :flush_cache, "package[#{flush_package_cache_name}]", :immediately
end
if new_resource.install_katello_agent && !new_resource.satellite_host.nil?
@@ -131,11 +136,16 @@ class Chef
end
action :unregister, description: "Unregister the node from RHSM." do
+ package flush_package_cache_name do
+ action :nothing
+ end
+
execute "Unregister from RHSM" do
command "subscription-manager unregister"
default_env true
action :run
only_if { registered_with_rhsm? }
+ notifies :flush_cache, "package[#{flush_package_cache_name}]", :immediately
notifies :run, "execute[Clean RHSM Config]", :immediately
end
@@ -148,6 +158,13 @@ class Chef
action_class do
#
+ # @return [String]
+ #
+ def flush_package_cache_name
+ "rhsm_register-#{new_resource.name}-flush_cache"
+ end
+
+ #
# @return [Symbol] dnf_package or yum_package depending on OS release
#
def package_resource