From f3735d2ba228fde8d2e119742e11bece4c2c78ac Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 21:01:20 -0800 Subject: [PATCH 1/2] Allow duplicate $required_packages Previously, if more than one apt::source required the same packages to be installed it would fail with a duplicate exec resource. This adds the name of the source resource to the exec and gives the exec a name, moving it to a command parameter for the exec. --- manifests/source.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 0512fa9..9f31fe9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -36,8 +36,9 @@ define apt::source( } if $required_packages != false { - exec { "${apt::params::provider} -y install ${required_packages}": - subscribe => File["${name}.list"], + exec { "Required packages: '${required_packages}' for ${name}": + command => "${apt::params::provider} -y install ${required_packages}", + subscribe => File["${name}.list"], refreshonly => true, } } From 1dcbf3d3035b5eb50839bb2e182663b539cf2d6a Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 21:04:57 -0800 Subject: [PATCH 2/2] Add tests for required_packages change This updates the tests for the apt::source defined type to use the new name for the exec resource and the new parameter for the same exec. --- spec/defines/source_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 95c5a54..b74a57d 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -89,12 +89,14 @@ describe 'apt::source', :type => :define do it { if param_hash[:required_packages] - should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", "subscribe" => "File[#{title}.list]", "refreshonly" => true }) else - should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", "subscribe" => "File[#{title}.list]", "refreshonly" => true })