Skip to content

Commit 41bbfba

Browse files
jhoblittekohl
authored andcommitted
manage discovery plugin config file
1 parent 0dcebed commit 41bbfba

File tree

5 files changed

+60
-3
lines changed

5 files changed

+60
-3
lines changed

examples/discovery.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include foreman_proxy
2+
include foreman_proxy::plugin::discovery

manifests/plugin/discovery.pp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# $install_images:: Download and extract the discovery image
88
#
99
# === Advanced parameters:
10+
# $enabled:: Whether the module is enabled or disabled.
11+
#
12+
# $version:: The version to ensure
13+
#
14+
# $listen_on:: When enabled, it's configured to listen on HTTPS (default), HTTP or both.
1015
#
1116
# $tftp_root:: TFTP root directory where extracted discovery image will be installed
1217
#
@@ -15,16 +20,21 @@
1520
# $image_name:: tarball with images
1621
#
1722
class foreman_proxy::plugin::discovery (
23+
Boolean $enabled = true,
24+
Optional[String] $version = undef,
25+
Foreman_proxy::ListenOn $listen_on = 'https',
1826
Boolean $install_images = $foreman_proxy::plugin::discovery::params::install_images,
1927
Stdlib::Absolutepath $tftp_root = $foreman_proxy::plugin::discovery::params::tftp_root,
2028
Stdlib::HTTPUrl $source_url = $foreman_proxy::plugin::discovery::params::source_url,
2129
String $image_name = $foreman_proxy::plugin::discovery::params::image_name,
2230
) inherits foreman_proxy::plugin::discovery::params {
23-
foreman_proxy::plugin { 'discovery':
31+
foreman_proxy::plugin::module { 'discovery':
32+
enabled => $enabled,
33+
feature => 'Discovery',
34+
listen_on => $listen_on,
35+
version => $version,
2436
}
2537

26-
foreman_proxy::feature { 'Discovery': }
27-
2838
if $install_images {
2939
$tftp_root_clean = regsubst($tftp_root, '/$', '')
3040

spec/acceptance/discovery_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'Scenario: install foreman-proxy with discovery plugin' do
4+
before(:context) { purge_foreman_proxy }
5+
6+
include_examples 'the example', 'discovery.pp'
7+
8+
it_behaves_like 'the default foreman proxy application'
9+
10+
describe command('curl -sk https://127.0.0.1:8443/features | grep -q discovery') do
11+
its(:exit_status) { should eq 0 }
12+
end
13+
end

spec/classes/foreman_proxy__plugin__discovery_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,39 @@
1515
'/var/lib/tftpboot'
1616
end
1717
end
18+
let(:etc_dir) do
19+
case facts[:osfamily]
20+
when 'FreeBSD', 'DragonFly'
21+
'/usr/local/etc'
22+
else
23+
'/etc'
24+
end
25+
end
26+
let(:group) do
27+
case facts[:osfamily]
28+
when 'FreeBSD', 'DragonFly'
29+
'foreman_proxy'
30+
else
31+
'foreman-proxy'
32+
end
33+
end
1834

1935
describe 'without paramaters' do
2036
it { should compile.with_all_deps }
2137
it { should contain_foreman_proxy__plugin('discovery') }
2238
it { should contain_foreman_proxy__feature('Discovery') }
2339
it { should_not contain_foreman_proxy__remote_file("#{tftproot}/boot/fdi-image-latest.tar") }
2440
it { should_not contain_exec('untar fdi-image-latest.tar') }
41+
42+
it do
43+
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/discovery.yml").with(
44+
ensure: 'file',
45+
owner: 'root',
46+
group: group,
47+
mode: '0640',
48+
content: %r{:enabled: https},
49+
)
50+
end
2551
end
2652

2753
describe 'with install_images => true' do

templates/plugin/discovery.yml.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
:enabled: <%= @module_enabled %>
3+
4+
# connection to discovered nodes
5+
#:node_scheme: https
6+
#:node_port: 8443

0 commit comments

Comments
 (0)