From 60e0e13fc55ba2f2d24252ae62b6d2f779bdb20a Mon Sep 17 00:00:00 2001 From: Justin Sherrill Date: Wed, 27 Apr 2016 15:11:21 -0400 Subject: [PATCH] Refs #12266 - fixing case where no certs exist undefined method [] for nil:NilClass /usr/share/katello-installer-base/modules/certs/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb:46:in last_rpm --- .../provider/certs_bootstrap_rpm/katello_ssl_tool.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb index 9ad66c4d..2fc2675f 100644 --- a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb +++ b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb @@ -20,9 +20,9 @@ def run '--requires', 'subscription-manager', '--post', post_script_file, *resource[:files]) - if resource[:alias] + if (rpm = last_rpm) && resource[:alias] File.delete(resource[:alias]) if File.exists?(resource[:alias]) - File.symlink(last_rpm, resource[:alias]) + File.symlink(rpm, resource[:alias]) end system('/sbin/restorecon ./*.rpm') end @@ -43,7 +43,8 @@ def last_rpm {'release' => release, 'rpm' => rpm} end - rpms.sort { |a,b| a['release'].to_i <=> b['release'].to_i }.last['rpm'] + rpm = rpms.sort { |a,b| a['release'].to_i <=> b['release'].to_i }.last + rpm['rpm'] if rpm end def next_release