From f759bc039a6a132a262a196450aad2ca9fd5f735 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Fri, 13 Jan 2012 15:29:47 -0800 Subject: [PATCH] (#11953) Apt::force passes $version to aptitude Previously, even if $version were passed to apt::force, aptitude would just install the default version of the package available. This updates the aptitude call to use the version string if it exists. If no version is passed, or if it is false, no version is added to the aptitude call. This also updates the rspec-puppet tests for the define, to reflect the changes to the exec. --- manifests/force.pp | 7 ++++++- spec/defines/force_spec.rb | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index ece532a..ec6f57e 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -6,7 +6,12 @@ define apt::force( $version = false ) { - exec { "/usr/bin/aptitude -y -t ${release} install ${name}": + $version_string = $version ? { + false => undef, + default => "=${version}", + } + + exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": unless => $version ? { false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index d040dc9..8477a08 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -15,7 +15,8 @@ describe 'apt::force', :type => :define do base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'") end let :exec_title do - "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec = "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec + (version ? "=#{version}" : "") end it { should contain_exec(exec_title).with_unless(unless_query) } end -- 2.45.2