class Chef::Resource::RhsmRegister
Public Instance Methods
ca_consumer_package_source()
click to toggle source
@return [String] The URI to fetch katello-ca-consumer-latest.noarch.rpm from
# File lib/chef/resource/rhsm_register.rb, line 158 def ca_consumer_package_source protocol = new_resource.https_for_ca_consumer ? "https" : "http" "#{protocol}://#{new_resource.satellite_host}/pub/katello-ca-consumer-latest.noarch.rpm" end
katello_cert_rpm_installed?()
click to toggle source
@return [Boolean] is katello-ca-consumer installed
# File lib/chef/resource/rhsm_register.rb, line 151 def katello_cert_rpm_installed? shell_out("rpm -qa").stdout.include?("katello-ca-consumer") end
package_resource()
click to toggle source
@return [Symbol] dnf_package or yum_package depending on OS release
# File lib/chef/resource/rhsm_register.rb, line 137 def package_resource node["platform_version"].to_i >= 8 ? :dnf_package : :yum_package end
register_command()
click to toggle source
# File lib/chef/resource/rhsm_register.rb, line 163 def register_command command = %w{subscription-manager register} if new_resource.activation_key unless new_resource.activation_key.empty? raise "Unable to register - you must specify organization when using activation keys" if new_resource.organization.nil? command << new_resource.activation_key.map { |key| "--activationkey=#{Shellwords.shellescape(key)}" } command << "--org=#{Shellwords.shellescape(new_resource.organization)}" command << "--name=#{Shellwords.shellescape(new_resource.system_name)}" if new_resource.system_name command << "--force" if new_resource.force return command.join(" ") end end if new_resource.username && new_resource.password raise "Unable to register - you must specify environment when using username/password" if new_resource.environment.nil? && using_satellite_host? command << "--username=#{Shellwords.shellescape(new_resource.username)}" command << "--password=#{Shellwords.shellescape(new_resource.password)}" command << "--environment=#{Shellwords.shellescape(new_resource.environment)}" if using_satellite_host? command << "--name=#{Shellwords.shellescape(new_resource.system_name)}" if new_resource.system_name command << "--auto-attach" if new_resource.auto_attach command << "--force" if new_resource.force return command.join(" ") end raise "Unable to create register command - you must specify activation_key or username/password" end
registered_with_rhsm?()
click to toggle source
@return [Boolean] is the node registered with RHSM
# File lib/chef/resource/rhsm_register.rb, line 144 def registered_with_rhsm? @registered ||= !shell_out("subscription-manager status").stdout.include?("Overall Status: Unknown") end
using_satellite_host?()
click to toggle source
# File lib/chef/resource/rhsm_register.rb, line 195 def using_satellite_host? !new_resource.satellite_host.nil? end