diff --git a/manifests/inspector.pp b/manifests/inspector.pp index 063373a3..a227c713 100644 --- a/manifests/inspector.pp +++ b/manifests/inspector.pp @@ -142,20 +142,24 @@ # Defautls to 'http://127.0.0.1:5000/v3' # # [*dnsmasq_ip_subnets*] -# (optional) List of hashes with keys: 'tag', 'ip_range', 'netmask', and -# 'gateway'. 'ip_range' is the only required key. Assigning multiple tagged -# subnets allow dnsmasq to serve dhcp request that came in via dhcp -# relay/helper. +# (optional) List of hashes with keys: 'tag', 'ip_range', 'netmask', +# 'gateway' and 'classless_static_routes'. 'ip_range' is the only required +# key. Assigning multiple tagged subnets allow dnsmasq to serve dhcp request +# that came in via dhcp relay/helper. # Example: # [{'ip_range' => '192.168.0.100,192.168.0.120'}, # {'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'}] +# {'tag' => 'subnet2', +# 'ip_range' => '192.168.2.100,192.168.2.200', +# 'netmask' => '255.255.255.0', +# 'gateway' => '192.168.2.254', +# 'classless_static_routes' => [{'destination' => '1.2.3.0/24', +# 'nexthop' => '192.168.2.1'}, +# {'destination' => '4.5.6.0/24', +# 'nexthop' => '192.168.2.1'}]}] # Defaults to [] # # [*dnsmasq_local_ip*] diff --git a/releasenotes/notes/inspector-dnsmasq-classless-static-route-support-71d8b7705b2683d4.yaml b/releasenotes/notes/inspector-dnsmasq-classless-static-route-support-71d8b7705b2683d4.yaml new file mode 100644 index 00000000..9425139c --- /dev/null +++ b/releasenotes/notes/inspector-dnsmasq-classless-static-route-support-71d8b7705b2683d4.yaml @@ -0,0 +1,18 @@ +--- +features: + - | + *Classless static routes* can now be configured for ironic inspector + subnets. The ``dnsmasq_ip_subnets`` has been extended to support the + ``classless_static_routes`` key in a subnet defention. This allow advanced + routing options to be pushed to the inspection ramdisk. For example:: + + dnsmasq_ip_subnets = [ + { 'tag' => 'subnet2', + 'ip_range' => '192.168.2.100,192.168.2.200', + 'netmask' => '255.255.255.0', + 'gateway' => '192.168.2.254', + 'classless_static_routes' => [ + {'destination' => '1.2.3.0/24', 'nexthop' => '192.168.2.1'}, + {'destination' => '4.5.6.0/24', 'nexthop' => '192.168.2.1'}], + }, + ] diff --git a/spec/classes/ironic_inspector_spec.rb b/spec/classes/ironic_inspector_spec.rb index a262c744..425d41e3 100644 --- a/spec/classes/ironic_inspector_spec.rb +++ b/spec/classes/ironic_inspector_spec.rb @@ -51,10 +51,14 @@ describe 'ironic::inspector' do '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' }], + { 'tag' => 'subnet2', + 'ip_range' => '192.168.2.100,192.168.2.200', + 'netmask' => '255.255.255.0', + 'gateway' => '192.168.2.254', + 'classless_static_routes' => [{'destination' => '1.2.3.0/24', + 'nexthop' => '192.168.2.1'}, + {'destination' => '4.5.6.0/24', + 'nexthop' => '192.168.2.1'}]}], :dnsmasq_local_ip => '192.168.0.1', :ipxe_timeout => 0, :http_port => 8088, @@ -157,6 +161,9 @@ describe 'ironic::inspector' do is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content( /dhcp-option=tag:subnet2,option:router,192.168.2.254/ ) + is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content( + /dhcp-option=tag:subnet2,option:classless-static-route,1.2.3.0\/24,192.168.2.1,4.5.6.0\/24,192.168.2.1/ + ) end it 'should contain file /tftpboot/pxelinux.cfg/default' do is_expected.to contain_file('/tftpboot/pxelinux.cfg/default').with( diff --git a/templates/inspector_dnsmasq_http.erb b/templates/inspector_dnsmasq_http.erb index c151991c..ebfc0cfc 100644 --- a/templates/inspector_dnsmasq_http.erb +++ b/templates/inspector_dnsmasq_http.erb @@ -19,6 +19,17 @@ dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %> dhcp-option=option:router,<%= s['gateway'] %> <% end -%> <% end -%> +<% if s['classless_static_routes'] -%> +<%- @_routes = [] -%> +<%- s['classless_static_routes'].each do |route| -%> +<%- @_routes << route['destination'] + ',' + route['nexthop'] -%> +<% end -%> +<% if s['tag'] -%> +dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') -%> +<% else -%> +dhcp-option=option:classless-static-route,<%= @_routes.join(',') -%> +<% end -%> +<% end -%> <% end -%> dhcp-sequential-ip dhcp-match=ipxe,175 diff --git a/templates/inspector_dnsmasq_tftp.erb b/templates/inspector_dnsmasq_tftp.erb index b9c0188b..2f8041d3 100644 --- a/templates/inspector_dnsmasq_tftp.erb +++ b/templates/inspector_dnsmasq_tftp.erb @@ -19,6 +19,17 @@ dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %> dhcp-option=option:router,<%= s['gateway'] %> <% end -%> <% end -%> +<% if s['classless_static_routes'] -%> +<%- @_routes = [] -%> +<%- s['classless_static_routes'].each do |route| -%> +<%- @_routes << route['destination'] + ',' + route['nexthop'] -%> +<% end -%> +<% if s['tag'] -%> +dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') -%> +<% else -%> +dhcp-option=option:classless-static-route,<%= @_routes.join(',') -%> +<% end -%> +<% end -%> <% end -%> dhcp-boot=pxelinux.0,localhost.localdomain,<%= @dnsmasq_local_ip %> dhcp-sequential-ip