summaryrefslogtreecommitdiff
path: root/lib/chef/resource
diff options
context:
space:
mode:
authorJason Barnett <jason.w.barnett@gmail.com>2020-03-24 09:58:41 -0400
committerJason Barnett <jason.w.barnett@gmail.com>2020-03-24 19:13:23 -0400
commit9e4e5ec0fb14b9e28d402b4d0e80f2ad79e88541 (patch)
treefa58ea0e76288186ede84259a1491bafae5800f4 /lib/chef/resource
parent4d4c85435ba49cea68113838c7113bb22d9ba88c (diff)
downloadchef-9e4e5ec0fb14b9e28d402b4d0e80f2ad79e88541.tar.gz
Add :https_for_ca_consumer property to rhsm_register resource
Signed-off-by: Jason Barnett <jason.w.barnett@gmail.com>
Diffstat (limited to 'lib/chef/resource')
-rw-r--r--lib/chef/resource/rhsm_register.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index aa3f47780e..263950e717 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -16,6 +16,7 @@
#
require_relative "../resource"
+require_relative "../dist"
require "shellwords" unless defined?(Shellwords)
class Chef
@@ -61,6 +62,11 @@ class Chef
description: "If true, the system will be registered even if it is already registered. Normally, any register operations will fail if the machine has already been registered.",
default: false, desired_state: false
+ property :https_for_ca_consumer, [TrueClass, FalseClass],
+ description: "If true, #{Chef::Dist::PRODUCT} will fetch the katello-ca-consumer-latest.noarch.rpm from the satellite_host using HTTPS.",
+ default: false, desired_state: false,
+ introduced: "15.9"
+
action :register do
description "Register the node with RHSM."
@@ -74,7 +80,7 @@ class Chef
end
remote_file "#{Chef::Config[:file_cache_path]}/katello-package.rpm" do
- source "http://#{new_resource.satellite_host}/pub/katello-ca-consumer-latest.noarch.rpm"
+ source ca_consumer_package_source
action :create
notifies :install, "#{package_resource}[katello-ca-consumer-latest]", :immediately
not_if { katello_cert_rpm_installed? }
@@ -133,6 +139,11 @@ class Chef
!cmd.stdout.match(/katello-ca-consumer/).nil?
end
+ 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
+
def register_command
command = %w{subscription-manager register}