-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This define introduced an abstraction for Foreman Proxy modules slightly more explicit than just the settings_file.
- Loading branch information
Showing
13 changed files
with
290 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# @summary Low level abstraction of Foreman Proxy modules | ||
# | ||
# Foreman Proxy internally has the concept of modules. Some modules have | ||
# providers or even multiple ones. That's not part of this definition. | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# When enabled, it's configured to listen on HTTPS (default), HTTP or both. | ||
# Unless the module explicitly needs HTTP (usually because clients needs it), | ||
# HTTPS should be chosen. | ||
# | ||
# @param feature | ||
# Each module is exposed as a feature to Foreman on registration. | ||
# foreman_proxy::register will validate the feature name is loaded and | ||
# advertised. | ||
# | ||
define foreman_proxy::module ( | ||
Boolean $enabled = false, | ||
Foreman_proxy::ListenOn $listen_on = 'https', | ||
String $feature = upcase($title), | ||
) { | ||
foreman_proxy::settings_file { $name: | ||
module => true, | ||
enabled => $enabled, | ||
feature => $feature, | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @summary The built in BMC module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::bmc ( | ||
Boolean $enabled = $foreman_proxy::bmc, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::bmc_listen_on, | ||
) { | ||
foreman_proxy::module { 'bmc': | ||
enabled => $enabled, | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @summary The built in DHCP module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::dhcp ( | ||
Boolean $enabled = $foreman_proxy::dhcp, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::dhcp_listen_on, | ||
) { | ||
foreman_proxy::module { 'dhcp': | ||
enabled => $enabled, | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @summary The built in DNS module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::dns ( | ||
Boolean $enabled = $foreman_proxy::dns, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::dns_listen_on, | ||
) { | ||
foreman_proxy::module { 'dns': | ||
enabled => $enabled, | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# @summary The built in HTTPBoot module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::httpboot ( | ||
Optional[Boolean] $enabled = $foreman_proxy::httpboot, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::httpboot_listen_on, | ||
) { | ||
$real_enabled = pick($enabled, $foreman_proxy::tftp) | ||
if $real_enabled { | ||
include foreman_proxy::module::tftp | ||
unless $foreman_proxy::module::tftp::enabled { | ||
fail('The HTTPBoot module depends on the TFTP module to be enabled') | ||
} | ||
} | ||
|
||
foreman_proxy::module { 'httpboot': | ||
enabled => $real_enabled, | ||
feature => 'HTTPBoot', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @summary The built in Logs module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::logs ( | ||
Boolean $enabled = $foreman_proxy::logs, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::logs_listen_on, | ||
) { | ||
foreman_proxy::module { 'logs': | ||
enabled => $enabled, | ||
feature => 'Logs', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @summary The built in Puppet module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::puppet ( | ||
Boolean $enabled = $foreman_proxy::puppet, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::puppet_listen_on, | ||
) { | ||
foreman_proxy::module { 'puppet': | ||
enabled => $enabled, | ||
feature => 'Puppet', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @summary The built in Puppet CA module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::puppetca ( | ||
Boolean $enabled = $foreman_proxy::puppetca, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::puppetca_listen_on, | ||
) { | ||
foreman_proxy::module { 'puppetca': | ||
enabled => $enabled, | ||
feature => 'Puppet CA', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @summary The built in Realm module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::realm ( | ||
Boolean $enabled = $foreman_proxy::realm, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::realm_listen_on, | ||
) { | ||
foreman_proxy::module { 'realm': | ||
enabled => $enabled, | ||
feature => 'Realm', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# @summary The built in Templates module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::templates ( | ||
Boolean $enabled = $foreman_proxy::templates, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::templates_listen_on, | ||
) { | ||
foreman_proxy::module { 'templates': | ||
enabled => $enabled, | ||
feature => 'Templates', | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @summary The built in TFTP module | ||
# | ||
# @param enabled | ||
# Whether the module is enabled or disabled. | ||
# | ||
# @param listen_on | ||
# Where to listen on. | ||
class foreman_proxy::module::tftp ( | ||
Boolean $enabled = $foreman_proxy::tftp, | ||
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::tftp_listen_on, | ||
) { | ||
foreman_proxy::module { 'tftp': | ||
enabled => $enabled, | ||
listen_on => $listen_on, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'spec_helper' | ||
|
||
describe 'foreman_proxy::module' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:title) { 'test' } | ||
let(:pre_condition) { 'include foreman_proxy::params' } | ||
|
||
context 'with defaults' do | ||
it { is_expected.to compile.with_all_deps } | ||
it do | ||
is_expected.to contain_foreman_proxy__settings_file('test') | ||
.with_enabled(false) | ||
.with_feature('TEST') | ||
.with_listen_on('https') | ||
end | ||
|
||
it { is_expected.not_to contain_foreman_proxy__feature('TEST') } | ||
end | ||
|
||
context 'with enabled => true' do | ||
let(:params) { { enabled: true } } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_foreman_proxy__settings_file('test').with_enabled(true) } | ||
it { is_expected.to contain_foreman_proxy__feature('TEST') } | ||
end | ||
|
||
context 'with feature' do | ||
let(:params) { { feature: 'Test' } } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_foreman_proxy__settings_file('test').with_feature('Test') } | ||
it { is_expected.not_to contain_foreman_proxy__feature('Test') } | ||
|
||
context 'with enabled => true' do | ||
let(:params) { super().merge(enabled: true) } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_foreman_proxy__settings_file('test').with_enabled(true).with_feature('Test') } | ||
it { is_expected.to contain_foreman_proxy__feature('Test') } | ||
end | ||
end | ||
|
||
context 'with listen_on => both' do | ||
let(:params) { { listen_on: 'both' } } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_foreman_proxy__settings_file('test').with_listen_on('both') } | ||
end | ||
|
||
context 'with listen_on => http' do | ||
let(:params) { { listen_on: 'http' } } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_foreman_proxy__settings_file('test').with_listen_on('http') } | ||
end | ||
end | ||
end | ||
end |