Skip to content

Commit

Permalink
Merge pull request #12909 from jasonwbarnett/jwb/backport-to-17
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccrae committed May 26, 2022
2 parents 8479f8f + 40e37f1 commit 8708ebe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/chef/resource/rhsm_register.rb
Expand Up @@ -118,12 +118,17 @@ class RhsmRegister < Chef::Resource
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?
Expand All @@ -132,11 +137,18 @@ class RhsmRegister < Chef::Resource
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

Expand All @@ -148,6 +160,13 @@ class RhsmRegister < Chef::Resource
end

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
#
Expand Down

0 comments on commit 8708ebe

Please sign in to comment.