Skip to content

Commit b1e101f

Browse files
committed
untar fdi-image as proxy user/group
To prevent fdi-image files from being chown'd on subsequent puppet agent runs.
1 parent 629c30f commit b1e101f

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

examples/discovery_images.pp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class { 'foreman_proxy':
2+
tftp => true,
3+
}
4+
class { 'foreman_proxy::plugin::discovery':
5+
install_images => true,
6+
}

manifests/plugin/discovery.pp

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
4949
cwd => "${tftp_root_clean}/boot",
5050
creates => "${tftp_root_clean}/boot/fdi-image/initrd0.img",
51+
user => $foreman_proxy::user,
52+
group => $foreman_proxy::group,
5153
}
5254
}
5355
}

spec/acceptance/discovery_spec.rb

+49-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,58 @@
11
require 'spec_helper_acceptance'
22

33
describe 'Scenario: install foreman-proxy with discovery plugin' do
4+
root = case host_inventory['facter']['os']['name']
5+
when 'Debian'
6+
'/srv/tftp'
7+
when 'Ubuntu'
8+
if host_inventory['facter']['os']['release']['major'].to_f >= 20.04
9+
'/srv/tftp'
10+
else
11+
'/var/lib/tftpboot'
12+
end
13+
else
14+
'/var/lib/tftpboot'
15+
end
16+
417
before(:context) { purge_foreman_proxy }
518

6-
include_examples 'the example', 'discovery.pp'
19+
context 'without params' do
20+
include_examples 'the example', 'discovery.pp'
21+
22+
it_behaves_like 'the default foreman proxy application'
23+
24+
describe command('curl -sk https://127.0.0.1:8443/features | grep -q discovery') do
25+
its(:exit_status) { should eq 0 }
26+
end
27+
end
28+
29+
context 'with install_images param' do
30+
include_examples 'the example', 'discovery_images.pp'
31+
32+
it_behaves_like 'the default foreman proxy application'
33+
34+
describe command('curl -sk https://127.0.0.1:8443/features | grep -q discovery') do
35+
its(:exit_status) { should eq 0 }
36+
end
737

8-
it_behaves_like 'the default foreman proxy application'
38+
%w[
39+
/boot/fdi-image-latest.tar
40+
/boot/fdi-image/initrd0.img
41+
/boot/fdi-image/vmlinuz0
42+
].each do |f|
43+
describe file(File.join(root, f)) do
44+
it { is_expected.to be_file }
45+
it { is_expected.to be_owned_by 'foreman-proxy' }
46+
it { is_expected.to be_grouped_into 'foreman-proxy' }
47+
it { is_expected.to be_mode '644' }
48+
end
49+
end
950

10-
describe command('curl -sk https://127.0.0.1:8443/features | grep -q discovery') do
11-
its(:exit_status) { should eq 0 }
51+
describe file(File.join(root, '/boot/fdi-image')) do
52+
it { is_expected.to be_directory }
53+
it { is_expected.to be_owned_by 'foreman-proxy' }
54+
it { is_expected.to be_grouped_into 'foreman-proxy' }
55+
it { is_expected.to be_mode '755' }
56+
end
1257
end
1358
end

0 commit comments

Comments
 (0)