Skip to content

Commit 3c59385

Browse files
authored
Add HDM smart proxy plugin
The HDM Smart Proxy plugins needs a configuration file, which specifies: - the HDM URL - optional HDM user and password User and password can be omitted, if HDM runs without authentication.
1 parent 26c1255 commit 3c59385

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

manifests/plugin/hdm.pp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# = Foreman Proxy HDM plugin
2+
#
3+
# This class installs the HDM plugin
4+
#
5+
# === Parameters:
6+
#
7+
# $hdm_url:: the API endpoint of your HDM installation
8+
#
9+
# $hdm_user:: email address of the API-role user inside of HDM - can be ommited if HDM runs unauthenticated
10+
#
11+
# $hdm_password:: password of the HDM API user - can be ommited if HDM runs unauthenticated
12+
#
13+
# === Advanced parameters:
14+
#
15+
# $enabled:: enables/disables the HDM plugin
16+
#
17+
# $listen_on:: proxy feature listens on http, https, or both
18+
#
19+
# $version:: plugin package version, it's passed to ensure parameter of package resource
20+
# can be set to specific version number, 'latest', 'present' etc.
21+
#
22+
class foreman_proxy::plugin::hdm (
23+
String[1] $hdm_url,
24+
Optional[String] $version = undef,
25+
Boolean $enabled = true,
26+
Foreman_proxy::ListenOn $listen_on = 'https',
27+
Optional[String[1]] $hdm_user = undef,
28+
Optional[String[1]] $hdm_password = undef,
29+
) {
30+
foreman_proxy::plugin::module { 'hdm':
31+
template_path => 'foreman_proxy/plugin/hdm.yml.erb',
32+
enabled => $enabled,
33+
feature => 'HDM',
34+
listen_on => $listen_on,
35+
version => $version,
36+
}
37+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'spec_helper'
2+
3+
describe 'foreman_proxy::plugin::hdm' do
4+
on_plugin_os.each do |os, os_facts|
5+
context "on #{os}" do
6+
let(:facts) { os_facts }
7+
let(:pre_condition) { 'include foreman_proxy' }
8+
let(:etc_dir) { '/etc' }
9+
let(:params) do
10+
{
11+
hdm_url: 'http://foreman.betadots.training:3000',
12+
hdm_user: '[email protected]',
13+
hdm_password: '1234567890'
14+
}
15+
end
16+
17+
describe 'with default settings' do
18+
it { is_expected.to compile.with_all_deps }
19+
it { is_expected.to contain_foreman_proxy__plugin('hdm') }
20+
21+
it 'should configure hdm.yml' do
22+
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/hdm.yml")
23+
.with_ensure('file')
24+
.with_owner('root')
25+
.with_group('foreman-proxy')
26+
27+
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/hdm.yml", [
28+
'---',
29+
':enabled: https',
30+
":hdm_url: 'http://foreman.betadots.training:3000'",
31+
":hdm_user: '[email protected]'",
32+
":hdm_password: '1234567890'"
33+
])
34+
end
35+
end
36+
end
37+
end
38+
end

templates/plugin/hdm.yml.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# HDM Smart Proxy
2+
---
3+
:enabled: <%= @module_enabled %>
4+
:hdm_url: '<%= scope.lookupvar("foreman_proxy::plugin::hdm::hdm_url") %>'
5+
<%- if scope.lookupvar("foreman_proxy::plugin::hdm::hdm_user") and scope.lookupvar("foreman_proxy::plugin::hdm::hdm_password") -%>
6+
:hdm_user: '<%= scope.lookupvar("foreman_proxy::plugin::hdm::hdm_user") %>'
7+
:hdm_password: '<%= scope.lookupvar("foreman_proxy::plugin::hdm::hdm_password") %>'
8+
<%- end -%>

0 commit comments

Comments
 (0)