diff --git a/manifests/inspector.pp b/manifests/inspector.pp index 5f041b06..1754dcaf 100644 --- a/manifests/inspector.pp +++ b/manifests/inspector.pp @@ -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', diff --git a/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml b/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml new file mode 100644 index 00000000..9578faca --- /dev/null +++ b/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml @@ -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. diff --git a/spec/classes/ironic_inspector_spec.rb b/spec/classes/ironic_inspector_spec.rb index f03fd414..fccb47d9 100644 --- a/spec/classes/ironic_inspector_spec.rb +++ b/spec/classes/ironic_inspector_spec.rb @@ -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( diff --git a/templates/inspector_dnsmasq_http.erb b/templates/inspector_dnsmasq_http.erb index e26101b5..54102620 100644 --- a/templates/inspector_dnsmasq_http.erb +++ b/templates/inspector_dnsmasq_http.erb @@ -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 diff --git a/templates/inspector_dnsmasq_tftp.erb b/templates/inspector_dnsmasq_tftp.erb index 0b1f24af..981bb6b7 100644 --- a/templates/inspector_dnsmasq_tftp.erb +++ b/templates/inspector_dnsmasq_tftp.erb @@ -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