Skip to content

Commit

Permalink
MODULES-1456 - make sure ruby is in path on PE
Browse files Browse the repository at this point in the history
Ruby is not in the path for all PE installations, so make sure the
concat script is run with ruby in the path.
  • Loading branch information
Morgan Haskel committed Feb 10, 2015
1 parent fa5c1cf commit 3b2e37a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
13 changes: 12 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@
# 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'))

# 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
# the concatfragments.sh script to potentially be installed in path that
# may not be accessible by a target non-root owner.
Expand All @@ -196,7 +207,7 @@
notify => File[$name],
subscribe => File[$fragdir],
unless => "${command} -t",
path => $::path,
path => $command_path,
require => [
File[$fragdir],
File["${fragdir}/fragments"],
Expand Down
3 changes: 3 additions & 0 deletions spec/unit/classes/concat_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:caller_module_name => 'Test',
:osfamily => 'Debian',
:id => 'root',
:is_pe => false,
}
end

Expand Down Expand Up @@ -55,6 +56,7 @@
:caller_module_name => 'Test',
:osfamily => 'Solaris',
:id => 'root',
:is_pe => false,
}
end

Expand All @@ -77,6 +79,7 @@
:caller_module_name => 'Test',
:osfamily => 'windows',
:id => 'batman',
:is_pe => false,
}
end

Expand Down
14 changes: 9 additions & 5 deletions spec/unit/defines/concat_fragment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:id => id,
:osfamily => 'Debian',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
let(:params) { params }
Expand Down Expand Up @@ -71,7 +72,7 @@

context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :target => false }}

it 'should fail' do
Expand All @@ -92,7 +93,7 @@

context 'any value other than \'present\' or \'absent\'' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }}

it 'should create a warning' do
Expand All @@ -113,7 +114,7 @@

context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :content => false, :target => '/etc/motd' }}

it 'should fail' do
Expand All @@ -134,7 +135,7 @@

context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :source => false, :target => '/etc/motd' }}

it 'should fail' do
Expand All @@ -155,7 +156,7 @@

context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
let(:params) {{ :order => false, :target => '/etc/motd' }}

it 'should fail' do
Expand All @@ -174,6 +175,7 @@
:concat_basedir => '/tmp',
:osfamily => 'Debian',
:id => 'root',
:is_pe => false,
}
end
let(:params) do
Expand All @@ -196,6 +198,7 @@
:concat_basedir => '/tmp',
:osfamily => 'Debian',
:id => 'root',
:is_pe => false,
}
end
let(:params) do
Expand All @@ -218,6 +221,7 @@
:concat_basedir => '/tmp',
:osfamily => 'Debian',
:id => 'root',
:is_pe => false,
}
end
let(:params) do
Expand Down
1 change: 1 addition & 0 deletions spec/unit/defines/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
:osfamily => 'Debian',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:kernel => 'Linux',
:is_pe => false,
}
end

Expand Down

0 comments on commit 3b2e37a

Please sign in to comment.