Skip to content

Commit 3b2e37a

Browse files
author
Morgan Haskel
committed
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.
1 parent fa5c1cf commit 3b2e37a

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

manifests/init.pp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@
187187
# remove extra whitespace from string interpolation to make testing easier
188188
$command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
189189

190+
# make sure ruby is in the path for PE
191+
if $::is_pe {
192+
if $::kernel == 'windows' {
193+
$command_path = "${::env_windows_installdir}/bin:${::path}"
194+
} else {
195+
$command_path = "/opt/puppet/bin:${::path}"
196+
}
197+
} else {
198+
$command_path = $::path
199+
}
200+
190201
# if puppet is running as root, this exec should also run as root to allow
191202
# the concatfragments.sh script to potentially be installed in path that
192203
# may not be accessible by a target non-root owner.
@@ -196,7 +207,7 @@
196207
notify => File[$name],
197208
subscribe => File[$fragdir],
198209
unless => "${command} -t",
199-
path => $::path,
210+
path => $command_path,
200211
require => [
201212
File[$fragdir],
202213
File["${fragdir}/fragments"],

spec/unit/classes/concat_setup_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
:caller_module_name => 'Test',
1212
:osfamily => 'Debian',
1313
:id => 'root',
14+
:is_pe => false,
1415
}
1516
end
1617

@@ -55,6 +56,7 @@
5556
:caller_module_name => 'Test',
5657
:osfamily => 'Solaris',
5758
:id => 'root',
59+
:is_pe => false,
5860
}
5961
end
6062

@@ -77,6 +79,7 @@
7779
:caller_module_name => 'Test',
7880
:osfamily => 'windows',
7981
:id => 'batman',
82+
:is_pe => false,
8083
}
8184
end
8285

spec/unit/defines/concat_fragment_spec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
:id => id,
3131
:osfamily => 'Debian',
3232
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
33+
:is_pe => false,
3334
}
3435
end
3536
let(:params) { params }
@@ -71,7 +72,7 @@
7172

7273
context 'false' do
7374
let(:title) { 'motd_header' }
74-
let(:facts) {{ :concat_basedir => '/tmp' }}
75+
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
7576
let(:params) {{ :target => false }}
7677

7778
it 'should fail' do
@@ -92,7 +93,7 @@
9293

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

9899
it 'should create a warning' do
@@ -113,7 +114,7 @@
113114

114115
context 'false' do
115116
let(:title) { 'motd_header' }
116-
let(:facts) {{ :concat_basedir => '/tmp' }}
117+
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
117118
let(:params) {{ :content => false, :target => '/etc/motd' }}
118119

119120
it 'should fail' do
@@ -134,7 +135,7 @@
134135

135136
context 'false' do
136137
let(:title) { 'motd_header' }
137-
let(:facts) {{ :concat_basedir => '/tmp' }}
138+
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
138139
let(:params) {{ :source => false, :target => '/etc/motd' }}
139140

140141
it 'should fail' do
@@ -155,7 +156,7 @@
155156

156157
context 'false' do
157158
let(:title) { 'motd_header' }
158-
let(:facts) {{ :concat_basedir => '/tmp' }}
159+
let(:facts) {{ :concat_basedir => '/tmp', :is_pe => false }}
159160
let(:params) {{ :order => false, :target => '/etc/motd' }}
160161

161162
it 'should fail' do
@@ -174,6 +175,7 @@
174175
:concat_basedir => '/tmp',
175176
:osfamily => 'Debian',
176177
:id => 'root',
178+
:is_pe => false,
177179
}
178180
end
179181
let(:params) do
@@ -196,6 +198,7 @@
196198
:concat_basedir => '/tmp',
197199
:osfamily => 'Debian',
198200
:id => 'root',
201+
:is_pe => false,
199202
}
200203
end
201204
let(:params) do
@@ -218,6 +221,7 @@
218221
:concat_basedir => '/tmp',
219222
:osfamily => 'Debian',
220223
:id => 'root',
224+
:is_pe => false,
221225
}
222226
end
223227
let(:params) do

spec/unit/defines/concat_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
:osfamily => 'Debian',
4141
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
4242
:kernel => 'Linux',
43+
:is_pe => false,
4344
}
4445
end
4546

0 commit comments

Comments
 (0)