From 396edff00ef624c75329c489ff8841505f95a36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= Date: Thu, 30 Jan 2014 13:59:56 +0100 Subject: [PATCH] fix getting the release name with lsb release This is newly broken in SLES11SP3, so we have to parse the lsb_release output manually. The code was copied from chef's lsb module. Change-Id: I97cf1a4e4f937d6c2bea035cc09c8c61d05825d6 --- recipes/default.rb | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index 53ffdaa5..0ce628b6 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -55,22 +55,19 @@ when 'rhel' when 'suse' if node['lsb']['description'].nil? - # Workaround for SLE11 - # - # On SLE11 ohai is broken and prefers lsb-release. We need to - # install it to be able to detect if recipe is run on openSUSE or SLES. - # - # https://bugzilla.novell.com/show_bug.cgi?id=809129 - # - # - install_lsb_release = package 'lsb-release' do - action :nothing + # Ohai lsb does not work at all on SLES11SP3 + # See https://tickets.opscode.com/browse/OHAI-454 + # Until then, copy chef's lsb_release parsing code from its lsb module. + package 'lsb-release' + + Mixlib::ShellOut.new('lsb_release -a').run_command.stdout.split("\n").each do |line| + case line + when /^Description:\s+(.+)$/ + node.set_unless['lsb']['description'] = Regexp.last_match[1] + when /^Release:\s+(.+)$/ + node.set_unless['lsb']['release'] = Regexp.last_match[1] + end end - reload_ohai = ohai 'reload_lsb' do - action :nothing - end - install_lsb_release.run_action(:install) - reload_ohai.run_action(:reload) end if node['lsb']['description'][/^SUSE Linux Enterprise Server/] release, patchlevel = node['platform_version'].split('.')