Puppet4 support: cobbler
* Fix cobbler specs and manifests Change-Id: I75d59e947f9bfd21dfaaef44a482af0f984025c6 Related-Bug: 1586480
This commit is contained in:
parent
7551125075
commit
2692dfa34a
|
@ -14,6 +14,7 @@ group :development, :test do
|
|||
gem 'puppet-lint-variable_contains_upcase', :require => 'false'
|
||||
gem 'puppet-lint-numericvariable', :require => 'false'
|
||||
gem 'json', :require => 'false'
|
||||
gem 'rspec-puppet-facts', :require => 'false'
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
|
|
|
@ -27,12 +27,14 @@ class cobbler::apache {
|
|||
},
|
||||
],
|
||||
aliases => [
|
||||
{ alias => '/cobbler/boot',
|
||||
{
|
||||
alias => '/cobbler/boot',
|
||||
path => '/var/lib/tftpboot',
|
||||
},
|
||||
],
|
||||
directories => [
|
||||
{ path => '/var/lib/tftpboot',
|
||||
{
|
||||
path => '/var/lib/tftpboot',
|
||||
options => ['Indexes', 'FollowSymLinks'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -101,14 +101,6 @@ class cobbler::server (
|
|||
}
|
||||
|
||||
if $apache_ssl_module {
|
||||
file { '/etc/apache2/mods-enabled/ssl.load':
|
||||
ensure => link,
|
||||
target => '/etc/apache2/mods-available/ssl.load',
|
||||
} ->
|
||||
file { '/etc/apache2/mods-enabled/ssl.conf':
|
||||
ensure => link,
|
||||
target => '/etc/apache2/mods-available/ssl.conf',
|
||||
} ->
|
||||
file { '/etc/apache2/sites-enabled/default-ssl':
|
||||
ensure => link,
|
||||
target => '/etc/apache2/sites-available/default-ssl',
|
||||
|
@ -151,7 +143,7 @@ class cobbler::server (
|
|||
ensure => present,
|
||||
path => '/usr/share/cobbler/web/settings.py',
|
||||
line => 'DEBUG = False',
|
||||
match => "^DEBUG.*$",
|
||||
match => '^DEBUG.*$',
|
||||
}
|
||||
|
||||
class { 'cobbler::apache':
|
||||
|
|
|
@ -5,79 +5,108 @@ describe "cobbler::apache" do
|
|||
shared_examples_for "cobbler configuration" do
|
||||
|
||||
context "with default params" do
|
||||
let(:aliases) do
|
||||
if Puppet.version.to_f >= 4.0
|
||||
[
|
||||
{
|
||||
"alias" => "/cobbler/boot",
|
||||
"path" => "/var/lib/tftpboot",
|
||||
}
|
||||
]
|
||||
else
|
||||
[
|
||||
["alias", "/cobbler/boot"],
|
||||
["path", "/var/lib/tftpboot"],
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
it "configures with the default params" do
|
||||
let(:directories) do
|
||||
if Puppet.version.to_f >= 4.0
|
||||
[
|
||||
{
|
||||
"path" => "/var/lib/tftpboot",
|
||||
"options" => ["Indexes", "FollowSymLinks"],
|
||||
},
|
||||
]
|
||||
else
|
||||
[
|
||||
["path", "/var/lib/tftpboot"],
|
||||
["options", ["Indexes", "FollowSymLinks"]],
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
should contain_class("apache").with(
|
||||
:server_signature => "Off",
|
||||
:trace_enable => "Off",
|
||||
:purge_configs => false,
|
||||
:default_vhost => false,
|
||||
)
|
||||
should contain_apache__vhost("cobbler non-ssl").with(
|
||||
:servername => "_default_",
|
||||
:port => 80,
|
||||
:docroot => "/var/www/html",
|
||||
:aliases => [
|
||||
["alias", "/cobbler/boot"], ["path", "/var/lib/tftpboot"]
|
||||
],
|
||||
:rewrites => [
|
||||
{
|
||||
"comment" => "Redirect root path to SSL Nailgun",
|
||||
"rewrite_cond" => ["%{HTTPS} off"],
|
||||
"rewrite_rule" => ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]
|
||||
},
|
||||
{
|
||||
"comment" => "Redirect other non-cobbler path to Nailgun",
|
||||
"rewrite_cond" => ["%{HTTPS} off", "%{REQUEST_URI} !^/(cblr|cobbler)"],
|
||||
"rewrite_rule" => ["(.*) http://%{HTTP_HOST}:8000%{REQUEST_URI} [R=301,L]"]
|
||||
},
|
||||
],
|
||||
:directories => [
|
||||
["path", "/var/lib/tftpboot"], ["options", ["Indexes", "FollowSymLinks"]]
|
||||
],
|
||||
)
|
||||
let(:ssl_rewrites) do
|
||||
if Puppet.version.to_f >= 4.0
|
||||
[
|
||||
{
|
||||
"comment" => "Redirect root path to SSL Nailgun",
|
||||
"rewrite_rule" => ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"],
|
||||
},
|
||||
]
|
||||
else
|
||||
[
|
||||
["comment", "Redirect root path to SSL Nailgun"],
|
||||
["rewrite_rule", ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
should contain_apache__vhost("cobbler ssl").with(
|
||||
:servername => "_default_",
|
||||
:port => 443,
|
||||
:docroot => "/var/www/html",
|
||||
:ssl => true,
|
||||
:ssl_cert => "/var/lib/fuel/keys/master/cobbler/cobbler.crt",
|
||||
:ssl_key => "/var/lib/fuel/keys/master/cobbler/cobbler.key",
|
||||
:rewrites => [
|
||||
["comment", "Redirect root path to SSL Nailgun"],
|
||||
["rewrite_rule", ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]]
|
||||
],
|
||||
:ssl_cipher => "ALL:!ADH:!EXPORT:!SSLv2:!MEDIUM:!LOW:+HIGH",
|
||||
:setenvif => [ "User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0" ],
|
||||
it "configures 'apache' class" do
|
||||
is_expected.to contain_class("apache").with(
|
||||
:server_signature => "Off",
|
||||
:trace_enable => "Off",
|
||||
:purge_configs => false,
|
||||
:default_vhost => false,
|
||||
)
|
||||
end
|
||||
|
||||
it "creates 'cobbler non-ssl' vhost" do
|
||||
is_expected.to contain_apache__vhost("cobbler non-ssl").with(
|
||||
:servername => "_default_",
|
||||
:port => 80,
|
||||
:docroot => "/var/www/html",
|
||||
:aliases => aliases,
|
||||
:rewrites => [
|
||||
{
|
||||
"comment" => "Redirect root path to SSL Nailgun",
|
||||
"rewrite_cond" => ["%{HTTPS} off"],
|
||||
"rewrite_rule" => ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]
|
||||
},
|
||||
{
|
||||
"comment" => "Redirect other non-cobbler path to Nailgun",
|
||||
"rewrite_cond" => ["%{HTTPS} off", "%{REQUEST_URI} !^/(cblr|cobbler)"],
|
||||
"rewrite_rule" => ["(.*) http://%{HTTP_HOST}:8000%{REQUEST_URI} [R=301,L]"]
|
||||
},
|
||||
],
|
||||
:directories => directories,
|
||||
)
|
||||
end
|
||||
|
||||
it "creates 'cobbler ssl' vhost" do
|
||||
is_expected.to contain_apache__vhost("cobbler ssl").with(
|
||||
:servername => "_default_",
|
||||
:port => 443,
|
||||
:docroot => "/var/www/html",
|
||||
:ssl => true,
|
||||
:ssl_cert => "/var/lib/fuel/keys/master/cobbler/cobbler.crt",
|
||||
:ssl_key => "/var/lib/fuel/keys/master/cobbler/cobbler.key",
|
||||
:rewrites => ssl_rewrites,
|
||||
:ssl_cipher => "ALL:!ADH:!EXPORT:!SSLv2:!MEDIUM:!LOW:+HIGH",
|
||||
:setenvif => ["User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0"],
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "on Debian platforms" do
|
||||
let :facts do
|
||||
@default_facts.merge(
|
||||
{ :osfamily => "Debian",
|
||||
:operatingsystem => "Debian",
|
||||
:operatingsystemrelease => "7",
|
||||
})
|
||||
on_supported_os(supported_os: supported_os).each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { facts }
|
||||
it_configures "cobbler configuration"
|
||||
end
|
||||
|
||||
it_configures "cobbler configuration"
|
||||
end
|
||||
|
||||
context "on RedHat platforms" do
|
||||
let :facts do
|
||||
@default_facts.merge(
|
||||
{ :osfamily => "RedHat",
|
||||
:operatingsystem => "RedHat",
|
||||
:operatingsystemrelease => "7.0",
|
||||
})
|
||||
end
|
||||
|
||||
it_configures "cobbler configuration"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,22 +3,22 @@ require 'spec_helper'
|
|||
describe 'cobbler' do
|
||||
|
||||
let(:default_params) { {
|
||||
:server => facts[:ipaddress],
|
||||
:production => 'prod',
|
||||
:domain_name => 'local',
|
||||
:name_server => facts[:ipaddress],
|
||||
:next_server => facts[:ipaddress],
|
||||
:dns_upstream => '8.8.8.8',
|
||||
:dns_domain => 'domain.tld',
|
||||
:dns_search => 'domain.tld',
|
||||
:dhcp_start_address => '10.0.0.201',
|
||||
:dhcp_end_address => '10.0.0.254',
|
||||
:dhcp_netmask => '255.255.255.0',
|
||||
:dhcp_gateway => facts[:ipaddress],
|
||||
:dhcp_interface => 'eth0',
|
||||
:cobbler_user => 'cobbler',
|
||||
:cobbler_password => 'cobbler',
|
||||
:pxetimeout => 0,
|
||||
:server => facts[:ipaddress],
|
||||
:production => 'prod',
|
||||
:domain_name => 'local',
|
||||
:name_server => facts[:ipaddress],
|
||||
:next_server => facts[:ipaddress],
|
||||
:dns_upstream => '8.8.8.8',
|
||||
:dns_domain => 'domain.tld',
|
||||
:dns_search => 'domain.tld',
|
||||
:dhcp_start_address => '10.0.0.201',
|
||||
:dhcp_end_address => '10.0.0.254',
|
||||
:dhcp_netmask => '255.255.255.0',
|
||||
:dhcp_gateway => facts[:ipaddress],
|
||||
:dhcp_interface => 'eth0',
|
||||
:cobbler_user => 'cobbler',
|
||||
:cobbler_password => 'cobbler',
|
||||
:pxetimeout => 0,
|
||||
} }
|
||||
|
||||
shared_examples_for 'cobbler configuration' do
|
||||
|
@ -26,53 +26,49 @@ describe 'cobbler' do
|
|||
default_params
|
||||
end
|
||||
|
||||
|
||||
context 'with default params' do
|
||||
let :params do
|
||||
default_params.merge!({})
|
||||
end
|
||||
|
||||
it 'configures with the default params' do
|
||||
should contain_class('cobbler')
|
||||
should contain_class('cobbler::apache')
|
||||
should contain_class('cobbler::packages')
|
||||
should contain_class('cobbler::selinux')
|
||||
should contain_class('cobbler::iptables')
|
||||
should contain_class('cobbler::server').with(
|
||||
:domain_name => params[:domain_name],
|
||||
:production => params[:production],
|
||||
:dns_upstream => params[:dns_upstream],
|
||||
:dns_domain => params[:dns_domain],
|
||||
:dns_search => params[:dns_search],
|
||||
:dhcp_gateway => params[:dhcp_gateway],
|
||||
:extra_admins_net => params[:extra_admins_nets])
|
||||
should contain_cobbler_digest_user(params[:cobbler_user]).with(
|
||||
:password => params[:cobbler_password])
|
||||
should contain_file_line('Change debug level in cobbler')
|
||||
it { is_expected.to contain_class('cobbler') }
|
||||
|
||||
it { is_expected.to contain_class('cobbler::apache') }
|
||||
|
||||
it { is_expected.to contain_class('cobbler::packages') }
|
||||
|
||||
it { is_expected.to contain_class('cobbler::selinux') }
|
||||
|
||||
it { is_expected.to contain_class('cobbler::iptables') }
|
||||
|
||||
it do
|
||||
is_expected.to contain_class('cobbler::server').with(
|
||||
:domain_name => params[:domain_name],
|
||||
:production => params[:production],
|
||||
:dns_upstream => params[:dns_upstream],
|
||||
:dns_domain => params[:dns_domain],
|
||||
:dns_search => params[:dns_search],
|
||||
:dhcp_gateway => params[:dhcp_gateway],
|
||||
:extra_admins_net => params[:extra_admins_nets],
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to contain_cobbler_digest_user(params[:cobbler_user]).with(
|
||||
:password => params[:cobbler_password],
|
||||
)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file_line('Change debug level in cobbler') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '7',
|
||||
})
|
||||
on_supported_os(supported_os: supported_os).each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { facts }
|
||||
it_configures "cobbler configuration"
|
||||
end
|
||||
|
||||
it_configures 'cobbler configuration'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '7.0',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'cobbler configuration'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
require 'rspec-puppet-facts'
|
||||
include RspecPuppetFacts
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
|
@ -14,3 +16,16 @@ RSpec.configure do |c|
|
|||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
||||
|
||||
def supported_os
|
||||
[
|
||||
{
|
||||
'operatingsystem' => 'CentOS',
|
||||
'operatingsystemrelease' => ['7.0'],
|
||||
},
|
||||
{
|
||||
'operatingsystem' => 'Ubuntu',
|
||||
'operatingsystemrelease' => ['14.04'],
|
||||
},
|
||||
]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue