Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional DHCP listen interfaces #399

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
#
# $dhcp_interface:: DHCP listen interface
#
# $dhcp_additional_interfaces:: Additional DHCP listen interfaces (in addition to dhcp_interface). Note: as opposed to dhcp_interface
# *no* subnet will be provisioned for any of the additional DHCP listen interfaces. Please configure any
# additional subnets using `dhcp::pool` and related resource types (provided by the theforeman/puppet-dhcp
# module).
#
# $dhcp_gateway:: DHCP pool gateway
#
# $dhcp_range:: Space-separated DHCP pool range
Expand Down Expand Up @@ -366,6 +371,7 @@
Array[String] $dhcp_option_domain = $::foreman_proxy::params::dhcp_option_domain,
Optional[Array[String]] $dhcp_search_domains = $::foreman_proxy::params::dhcp_search_domains,
String $dhcp_interface = $::foreman_proxy::params::dhcp_interface,
Array[String] $dhcp_additional_interfaces = $::foreman_proxy::params::dhcp_additional_interfaces,
Optional[String] $dhcp_gateway = $::foreman_proxy::params::dhcp_gateway,
Variant[Undef, Boolean, String] $dhcp_range = $::foreman_proxy::params::dhcp_range,
Optional[String] $dhcp_pxeserver = $::foreman_proxy::params::dhcp_pxeserver,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
$dhcp_provider = 'isc'
$dhcp_subnets = []
$dhcp_interface = 'eth0'
$dhcp_additional_interfaces = []
$dhcp_gateway = '192.168.100.1'
$dhcp_range = undef
$dhcp_option_domain = [$::domain]
Expand Down
2 changes: 1 addition & 1 deletion manifests/proxydhcp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class { '::dhcp':
dnsdomain => $foreman_proxy::dhcp_option_domain,
nameservers => $nameservers,
interfaces => [$foreman_proxy::dhcp_interface],
interfaces => [$foreman_proxy::dhcp_interface] + $foreman_proxy::dhcp_additional_interfaces,
pxeserver => $ip,
pxefilename => 'pxelinux.0',
omapi_name => $foreman_proxy::dhcp_key_name,
Expand Down
97 changes: 97 additions & 0 deletions spec/classes/foreman_proxy__proxydhcp__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,103 @@
it { should_not contain_class('dhcp::failover') }
end

context "with additional dhcp listen interfaces" do
let :facts do
facts.merge({:ipaddress_eth0 => '127.0.1.1',
:netmask_eth0 => '255.0.0.0',
:network_eth0 => '127.0.0.0'})
end

let :pre_condition do
"class {'foreman_proxy':
dhcp_gateway => '127.0.0.254',
dhcp_additional_interfaces => [ 'vlan8', 'vlan9', 'vlan120' ],
}"
end

it do should contain_class('dhcp').with(
'dnsdomain' => ['example.com'],
'nameservers' => ['127.0.1.1'],
'interfaces' => ['eth0', 'vlan8', 'vlan9', 'vlan120' ],
'pxeserver' => '127.0.1.1',
'pxefilename' => 'pxelinux.0'
) end

it do should contain_dhcp__pool('example.com').with(
'network' => '127.0.0.0',
'mask' => '255.0.0.0',
'range' => nil,
'gateway' => '127.0.0.254',
'failover' => nil
) end

it { should_not contain_class('dhcp::failover') }
end

context "with one additional dhcp listen interface" do
let :facts do
facts.merge({:ipaddress_eth0 => '127.0.1.1',
:netmask_eth0 => '255.0.0.0',
:network_eth0 => '127.0.0.0'})
end

let :pre_condition do
"class {'foreman_proxy':
dhcp_gateway => '127.0.0.254',
dhcp_additional_interfaces => [ 'vlan83' ]
}"
end

it do should contain_class('dhcp').with(
'dnsdomain' => ['example.com'],
'nameservers' => ['127.0.1.1'],
'interfaces' => ['eth0', 'vlan83'],
'pxeserver' => '127.0.1.1',
'pxefilename' => 'pxelinux.0'
) end

it do should contain_dhcp__pool('example.com').with(
'network' => '127.0.0.0',
'mask' => '255.0.0.0',
'range' => nil,
'gateway' => '127.0.0.254',
'failover' => nil
) end

it { should_not contain_class('dhcp::failover') }
end

context "with additional dhcp listen interfaces wrongly specified as String data type" do
let :facts do
facts.merge({:ipaddress_eth0 => '127.0.1.1',
:netmask_eth0 => '255.0.0.0',
:network_eth0 => '127.0.0.0'})
end

let :pre_condition do
"class {'foreman_proxy':
dhcp_gateway => '127.0.0.254',
dhcp_additional_interfaces => 'vlan55',
}"
end
it { should raise_error(Puppet::PreformattedError, /expects an Array value, got String/) }
end

context "with additional dhcp listen interfaces wrongly specified as Hash data type" do
let :facts do
facts.merge({:ipaddress_eth0 => '127.0.1.1',
:netmask_eth0 => '255.0.0.0',
:network_eth0 => '127.0.0.0'})
end

let :pre_condition do
"class {'foreman_proxy':
dhcp_gateway => '127.0.0.254',
dhcp_additional_interfaces => { 'name' => 'vlan55' }
}"
end
it { should raise_error(Puppet::PreformattedError, /expects an Array value, got Struct/) }
end

context "with dhcp_search_domains" do
let :facts do
Expand Down