diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-02-27 11:41:03 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-02-27 11:41:03 -0800 |
commit | 81e3a990bb1960392700f76153f896132d3ca7ed (patch) | |
tree | 9195d92759534e45ff5d2d08f49f6d4f0b137735 /lib/chef | |
parent | 36a727691ea93d1f5fe8cf267fae5dd92516a9f0 (diff) | |
download | chef-81e3a990bb1960392700f76153f896132d3ca7ed.tar.gz |
Update the rhsm_erata* and rhsm_register resources for RHEL 8
These need to use dnf instead of yum_package where they can. I also
enabled these for unified_mode and moved some only_if logic outside the
resources for cleaner logging. These should really all just get
converted to use shell_out and a nice converge_by
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/resource/rhsm_errata.rb | 5 | ||||
-rw-r--r-- | lib/chef/resource/rhsm_errata_level.rb | 10 | ||||
-rw-r--r-- | lib/chef/resource/rhsm_register.rb | 14 |
3 files changed, 16 insertions, 13 deletions
diff --git a/lib/chef/resource/rhsm_errata.rb b/lib/chef/resource/rhsm_errata.rb index 7442bf99f2..8be53340dc 100644 --- a/lib/chef/resource/rhsm_errata.rb +++ b/lib/chef/resource/rhsm_errata.rb @@ -1,5 +1,5 @@ # -# Copyright:: 2015-2018 Chef Software, Inc. +# Copyright:: 2015-2020 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,7 @@ require_relative "../resource" class Chef class Resource class RhsmErrata < Chef::Resource + unified_mode true resource_name :rhsm_errata provides(:rhsm_errata) { true } @@ -36,7 +37,7 @@ class Chef description "Installs a package for a specific errata ID." execute "Install errata packages for #{new_resource.errata_id}" do - command "yum update --advisory #{new_resource.errata_id} -y" + command "{rhel8? ? 'dnf' : 'yum'} update --advisory #{new_resource.errata_id} -y" default_env true action :run end diff --git a/lib/chef/resource/rhsm_errata_level.rb b/lib/chef/resource/rhsm_errata_level.rb index 2bb0006a38..47b43055f9 100644 --- a/lib/chef/resource/rhsm_errata_level.rb +++ b/lib/chef/resource/rhsm_errata_level.rb @@ -1,5 +1,5 @@ # -# Copyright:: 2015-2018 Chef Software, Inc. +# Copyright:: 2015-2020 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,7 @@ require_relative "../resource" class Chef class Resource class RhsmErrataLevel < Chef::Resource + unified_mode true resource_name :rhsm_errata_level provides(:rhsm_errata_level) { true } @@ -35,13 +36,12 @@ class Chef action :install do description "Install all packages of the specified errata level." - yum_package "yum-plugin-security" do - action :install - only_if { node["platform_version"].to_i == 6 } + if rhel6? + yum_package "yum-plugin-security" end execute "Install any #{new_resource.errata_level} errata" do - command "yum update --sec-severity=#{new_resource.errata_level.capitalize} -y" + command "{rhel8? ? 'dnf' : 'yum'} update --sec-severity=#{new_resource.errata_level.capitalize} -y" default_env true action :run end diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb index cfaa55124c..7d1523ce72 100644 --- a/lib/chef/resource/rhsm_register.rb +++ b/lib/chef/resource/rhsm_register.rb @@ -1,5 +1,5 @@ # -# Copyright:: 2015-2018 Chef Software, Inc. +# Copyright:: 2015-2020 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,6 +21,7 @@ require "shellwords" unless defined?(Shellwords) class Chef class Resource class RhsmRegister < Chef::Resource + unified_mode true resource_name :rhsm_register provides(:rhsm_register) { true } @@ -69,11 +70,13 @@ class Chef remote_file "#{Chef::Config[:file_cache_path]}/katello-package.rpm" do source "http://#{new_resource.satellite_host}/pub/katello-ca-consumer-latest.noarch.rpm" action :create - notifies :install, "yum_package[katello-ca-consumer-latest]", :immediately + notifies :install, "{rhel8? ? 'dnf' : 'yum'}_package[katello-ca-consumer-latest]", :immediately not_if { katello_cert_rpm_installed? } end - yum_package "katello-ca-consumer-latest" do + resource_type = rhel8? ? :dnf_package : :yum_package + + declare_resource(resource_type, "katello-ca-consumer-latest") do options "--nogpgcheck" source "#{Chef::Config[:file_cache_path]}/katello-package.rpm" action :nothing @@ -92,9 +95,8 @@ class Chef not_if { registered_with_rhsm? } unless new_resource.force end - yum_package "katello-agent" do - action :install - only_if { new_resource.install_katello_agent && !new_resource.satellite_host.nil? } + if new_resource.install_katello_agent && !new_resource.satellite_host.nil? + package "katello-agent" end end |