MODULES-1456 - make sure ruby is in path on PE

Ruby is not in the path for all PE installations, so make sure the
concat script is run with ruby in the path.
This commit is contained in:
Morgan Haskel 2014-11-14 15:53:36 -08:00
parent fa5c1cfac3
commit 3b2e37ab1e
4 changed files with 25 additions and 6 deletions

View file

@ -187,6 +187,17 @@ define concat(
# remove extra whitespace from string interpolation to make testing easier # remove extra whitespace from string interpolation to make testing easier
$command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
# make sure ruby is in the path for PE
if $::is_pe {
if $::kernel == 'windows' {
$command_path = "${::env_windows_installdir}/bin:${::path}"
} else {
$command_path = "/opt/puppet/bin:${::path}"
}
} else {
$command_path = $::path
}
# if puppet is running as root, this exec should also run as root to allow # if puppet is running as root, this exec should also run as root to allow
# the concatfragments.sh script to potentially be installed in path that # the concatfragments.sh script to potentially be installed in path that
# may not be accessible by a target non-root owner. # may not be accessible by a target non-root owner.
@ -196,7 +207,7 @@ define concat(
notify => File[$name], notify => File[$name],
subscribe => File[$fragdir], subscribe => File[$fragdir],
unless => "${command} -t", unless => "${command} -t",
path => $::path, path => $command_path,
require => [ require => [
File[$fragdir], File[$fragdir],
File["${fragdir}/fragments"], File["${fragdir}/fragments"],

View file

@ -11,6 +11,7 @@ describe 'concat::setup', :type => :class do
:caller_module_name => 'Test', :caller_module_name => 'Test',
:osfamily => 'Debian', :osfamily => 'Debian',
:id => 'root', :id => 'root',
:is_pe => false,
} }
end end
@ -55,6 +56,7 @@ describe 'concat::setup', :type => :class do
:caller_module_name => 'Test', :caller_module_name => 'Test',
:osfamily => 'Solaris', :osfamily => 'Solaris',
:id => 'root', :id => 'root',
:is_pe => false,
} }
end end
@ -77,6 +79,7 @@ describe 'concat::setup', :type => :class do
:caller_module_name => 'Test', :caller_module_name => 'Test',
:osfamily => 'windows', :osfamily => 'windows',
:id => 'batman', :id => 'batman',
:is_pe => false,
} }
end end

View file

@ -30,6 +30,7 @@ describe 'concat::fragment', :type => :define do
:id => id, :id => id,
:osfamily => 'Debian', :osfamily => 'Debian',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
} }
end end
let(:params) { params } let(:params) { params }
@ -71,7 +72,7 @@ describe 'concat::fragment', :type => :define do
context 'false' do context 'false' do
let(:title) { 'motd_header' } let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }} let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :target => false }} let(:params) {{ :target => false }}
it 'should fail' do it 'should fail' do
@ -92,7 +93,7 @@ describe 'concat::fragment', :type => :define do
context 'any value other than \'present\' or \'absent\'' do context 'any value other than \'present\' or \'absent\'' do
let(:title) { 'motd_header' } let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }} let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }}
it 'should create a warning' do it 'should create a warning' do
@ -113,7 +114,7 @@ describe 'concat::fragment', :type => :define do
context 'false' do context 'false' do
let(:title) { 'motd_header' } let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }} let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :content => false, :target => '/etc/motd' }} let(:params) {{ :content => false, :target => '/etc/motd' }}
it 'should fail' do it 'should fail' do
@ -134,7 +135,7 @@ describe 'concat::fragment', :type => :define do
context 'false' do context 'false' do
let(:title) { 'motd_header' } let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }} let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :source => false, :target => '/etc/motd' }} let(:params) {{ :source => false, :target => '/etc/motd' }}
it 'should fail' do it 'should fail' do
@ -155,7 +156,7 @@ describe 'concat::fragment', :type => :define do
context 'false' do context 'false' do
let(:title) { 'motd_header' } let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }} let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :order => false, :target => '/etc/motd' }} let(:params) {{ :order => false, :target => '/etc/motd' }}
it 'should fail' do it 'should fail' do
@ -174,6 +175,7 @@ describe 'concat::fragment', :type => :define do
:concat_basedir => '/tmp', :concat_basedir => '/tmp',
:osfamily => 'Debian', :osfamily => 'Debian',
:id => 'root', :id => 'root',
:is_pe => false,
} }
end end
let(:params) do let(:params) do
@ -196,6 +198,7 @@ describe 'concat::fragment', :type => :define do
:concat_basedir => '/tmp', :concat_basedir => '/tmp',
:osfamily => 'Debian', :osfamily => 'Debian',
:id => 'root', :id => 'root',
:is_pe => false,
} }
end end
let(:params) do let(:params) do
@ -218,6 +221,7 @@ describe 'concat::fragment', :type => :define do
:concat_basedir => '/tmp', :concat_basedir => '/tmp',
:osfamily => 'Debian', :osfamily => 'Debian',
:id => 'root', :id => 'root',
:is_pe => false,
} }
end end
let(:params) do let(:params) do

View file

@ -40,6 +40,7 @@ describe 'concat', :type => :define do
:osfamily => 'Debian', :osfamily => 'Debian',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:kernel => 'Linux', :kernel => 'Linux',
:is_pe => false,
} }
end end