summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <john.mccrae@progress.com>2022-05-26 03:39:52 +0000
committerGitHub <noreply@github.com>2022-05-26 03:39:52 +0000
commit8708ebeed1c2004b257d2b2175358852aa28fc0f (patch)
treee7c07e385da87ca460374495d5bf92fa06e8f642
parent8479f8fa1e02deb69429b2732c1a84030759849d (diff)
parent40e37f1a7680041b192eb4558192a8c87d56156d (diff)
downloadchef-8708ebeed1c2004b257d2b2175358852aa28fc0f.tar.gz
Merge pull request #12909 from jasonwbarnett/jwb/backport-to-17
-rw-r--r--lib/chef/resource/rhsm_register.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index 8a7d748920..71af5b0098 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -118,12 +118,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?
@@ -132,11 +137,18 @@ class Chef
end
action :unregister, description: "Unregister the node from RHSM." do
+ description "Unregister the node from RHSM."
+
+ 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
@@ -149,6 +161,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