Multiple DHCP Subnets for Ironic Inspector

Add parameter 'dnsmasq_ip_subnets' and enable template to
configure dhcp-range and dhcp-option 'option:router' for
additional subnets in Ironic Inspector dnsmasq.

Implements: blueprint tripleo-routed-networks-ironic-inspector
Closes-Bug: #1637503
Change-Id: Ie49b07ffe948576f5d9330cf11ee014aef4b282d
This commit is contained in:
Harald Jensas 2017-02-22 01:58:44 +01:00
parent 66bdf453c7
commit 9041a3af23
5 changed files with 54 additions and 0 deletions

@ -115,6 +115,20 @@
# (optional) IP range to use for nodes being introspected
# Defaults to '192.168.0.100,192.168.0.120'
#
# [*dnsmasq_ip_subnets*]
# (optional) List of hashes with keys: 'tag', 'ip_range', 'netmask', and
# 'gateway'. Assigning additional subnets allow dnsmasq to serve dhcp
# request that came in via dhcp relay/helper.
# [ { tag => 'subnet1',
# ip_range => '192.168.0.100,192.168.0.200',
# netmask => '255.255.255.0',
# gateway => '192.168.0.254' },
# { tag => 'subnet2',
# ip_range => '192.168.1.100,192.168.1.200',
# netmask => '255.255.255.0',
# gateway => '192.168.1.254' } ]
# Defaults to undef
#
# [*dnsmasq_local_ip*]
# (optional) IP interface for the dnsmasq process
# Defaults to '192.168.0.1'
@ -202,6 +216,7 @@ class ironic::inspector (
$swift_tenant_name = 'services',
$swift_auth_url = 'http://127.0.0.1:5000/v2.0',
$dnsmasq_ip_range = '192.168.0.100,192.168.0.120',
$dnsmasq_ip_subnets = undef,
$dnsmasq_local_ip = '192.168.0.1',
$sync_db = true,
$ramdisk_collectors = 'default',

@ -0,0 +1,6 @@
---
features:
- Assigning additional subnets allow dnsmasq to serve dhcp request that came
in via dhcp relay/helper.
Adds parameter 'dnsmasq_ip_subnets' and enable configuration of dhcp-range
and dhcp-option 'option:router' for additional subnets in dnsmasq.

@ -46,6 +46,7 @@ describe 'ironic::inspector' do
:swift_tenant_name => 'services',
:swift_auth_url => 'http://127.0.0.1:5000/v2.0',
:dnsmasq_ip_range => '192.168.0.100,192.168.0.120',
:dnsmasq_ip_subnets => false,
:dnsmasq_local_ip => '192.168.0.1',
:ipxe_timeout => 0,
:http_port => 8088,
@ -159,6 +160,14 @@ describe 'ironic::inspector' do
:detect_boot_mode => true,
:node_not_found_hook => 'enroll',
:discovery_default_driver => 'pxe_ipmitool',
:dnsmasq_ip_subnets => [ { 'tag' => 'subnet1',
'ip_range' => '192.168.1.100,192.168.1.200',
'netmask' => '255.255.255.0',
'gateway' => '192.168.1.254' },
{ 'tag' => 'subnet2',
'ip_range' => '192.168.2.100,192.168.2.200',
'netmask' => '255.255.255.0',
'gateway' => '192.168.2.254' } ],
)
end
it 'should replace default parameter with new value' do
@ -183,6 +192,18 @@ describe 'ironic::inspector' do
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-boot=tag:ipxe,http:\/\/192.168.0.1:3816\/inspector.ipxe/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-range=set:subnet1,192.168.1.100,192.168.1.200,255.255.255.0,29/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:subnet1,option:router,192.168.1.254/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-range=set:subnet2,192.168.2.100,192.168.2.200,255.255.255.0,29/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:subnet2,option:router,192.168.2.254/
)
end
it 'should contain file /var/www/httpboot/inspector.ipxe' do
is_expected.to contain_file('/var/www/httpboot/inspector.ipxe').with(

@ -1,6 +1,12 @@
port=0
interface=<%= @dnsmasq_interface %>
bind-interfaces
<% if @dnsmasq_ip_subnets.is_a?(Array) -%>
<% @dnsmasq_ip_subnets.each do |s| -%>
dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,<%= s['netmask'] -%>,29
dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %>
<% end -%>
<% end -%>
dhcp-range=<%= @dnsmasq_ip_range %>,29
dhcp-sequential-ip
dhcp-match=ipxe,175

@ -1,6 +1,12 @@
port=0
interface=<%= @dnsmasq_interface %>
bind-interfaces
<% if @dnsmasq_ip_subnets.is_a?(Array) -%>
<% @dnsmasq_ip_subnets.each do |s| -%>
dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,<%= s['netmask'] -%>,29
dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %>
<% end -%>
<% end -%>
dhcp-range=<%= @dnsmasq_ip_range %>,29
dhcp-boot=pxelinux.0,localhost.localdomain,<%= @dnsmasq_local_ip %>
dhcp-sequential-ip