From 90f862ce25842367e5065e4fd588933dc6784eed Mon Sep 17 00:00:00 2001 From: Harald Jensas Date: Thu, 2 Mar 2017 21:34:51 +0100 Subject: [PATCH] Deprecate 'dnsmasq_ip_range' replaced by 'dnsmasq_ip_subnets' With support for multiple subnets in Ironic Inspector dnsmasq a new parameter 'dnsmasq_ip_subnets' was added. With this new parameter the 'dnsmasq_ip_range' is redundant and should be deprecated. Change-Id: I07cbdd5e5573df23d6bdbfff4588cd870be933d9 --- manifests/inspector.pp | 48 ++++++---- ...rks-ironic-inspector-7ccc2087fc83c052.yaml | 35 ++++++- spec/classes/ironic_inspector_spec.rb | 96 ++++++++++--------- templates/inspector_dnsmasq_http.erb | 15 ++- templates/inspector_dnsmasq_tftp.erb | 15 ++- 5 files changed, 138 insertions(+), 71 deletions(-) diff --git a/manifests/inspector.pp b/manifests/inspector.pp index b598b625..8906cee3 100644 --- a/manifests/inspector.pp +++ b/manifests/inspector.pp @@ -127,23 +127,22 @@ # (optional) Keystone authentication URL for Swift # Defautls to 'http://127.0.0.1:5000/v2.0' # -# [*dnsmasq_ip_range*] -# (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 +# '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. +# 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'}] +# Defaults to [] # # [*dnsmasq_local_ip*] # (optional) IP interface for the dnsmasq process @@ -207,6 +206,9 @@ # (optional) Enable setting of IPMI credentials # Defaults to $::os::service_default # +# [*dnsmasq_ip_range*] +# (optional) IP range to use for nodes being introspected +# Defaults to undef class ironic::inspector ( $package_ensure = 'present', $enabled = true, @@ -235,8 +237,7 @@ class ironic::inspector ( $swift_project_domain_name = $::os_service_default, $swift_user_domain_name = $::os_service_default, $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_ip_subnets = [], $dnsmasq_local_ip = '192.168.0.1', $sync_db = true, $ramdisk_collectors = 'default', @@ -250,6 +251,7 @@ class ironic::inspector ( $node_not_found_hook = $::os_service_default, $discovery_default_driver = $::os_service_default, # DEPRECATED + $dnsmasq_ip_range = undef, $enable_uefi = undef, $enable_setting_ipmi_credentials = $::os_service_default, ) { @@ -268,6 +270,18 @@ class ironic::inspector ( warning('enable_setting_ipmi_credentials is deprecated') } + if !is_array($dnsmasq_ip_subnets) { + fail('Invalid data type, parameter dnsmasq_ip_subnets must be Array type') + } + + if $dnsmasq_ip_range { + warning('dnsmasq_ip_range is deprecated, replaced by dnsmasq_ip_subnets') + $dnsmasq_ip_subnets_real = concat($dnsmasq_ip_subnets, + {'ip_range' => $dnsmasq_ip_range}) + } else { + $dnsmasq_ip_subnets_real = $dnsmasq_ip_subnets + } + if $enable_uefi == undef { warning('UEFI will be enabled by default starting with Pike') } else { diff --git a/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml b/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml index 9578faca..d11b40f2 100644 --- a/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml +++ b/releasenotes/notes/routed-networks-ironic-inspector-7ccc2087fc83c052.yaml @@ -1,6 +1,33 @@ --- 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. + - | + Assigning additional subnets allow dnsmasq to serve dhcp request that came + in via dhcp relay/helper. New parameter 'dnsmasq_ip_subnets' enable + configuration of dhcp-range and dhcp-option 'option:router' for multiple + subnets in dnsmasq. + + Example:: + + $dnsmasq_ip_subnets = [{'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'}] + +deprecations: + - The "ironic::inspector::dnsmasq_ip_range" parameter was deprecated in favor + of "ironic::inspector::dnsmasq_ip_subnets" +upgrade: + - | + Replace usage of "ironic::inspector::dnsmasq_ip_range" with + "ironic::inspector::dnsmasq_ip_subnets". For example, if you have:: + + $dnsmasq_ip_range = '192.168.0.100,192.168.0.120' + + replace with:: + + $dnsmasq_ip_subnets = [{'ip_range' => '192.168.0.100,192.168.0.120'}] diff --git a/spec/classes/ironic_inspector_spec.rb b/spec/classes/ironic_inspector_spec.rb index 7e1a9b17..afa6e835 100644 --- a/spec/classes/ironic_inspector_spec.rb +++ b/spec/classes/ironic_inspector_spec.rb @@ -26,32 +26,40 @@ describe 'ironic::inspector' do end let :params do - { :package_ensure => 'present', - :enabled => true, - :pxe_transfer_protocol => 'tftp', - :enable_uefi => false, - :auth_strategy => 'keystone', - :dnsmasq_interface => 'br-ctlplane', - :ramdisk_logs_dir => '/var/log/ironic-inspector/ramdisk/', - :keep_ports => 'all', - :store_data => 'none', - :ironic_auth_type => 'password', - :ironic_username => 'ironic', - :ironic_tenant_name => 'services', - :ironic_auth_url => 'http://127.0.0.1:5000/v2.0', - :ironic_max_retries => 30, - :ironic_retry_interval => 2, - :swift_auth_type => 'password', - :swift_username => 'ironic', - :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, - :tftp_root => '/tftpboot', - :http_root => '/httpboot', } + { :package_ensure => 'present', + :enabled => true, + :pxe_transfer_protocol => 'tftp', + :enable_uefi => false, + :auth_strategy => 'keystone', + :dnsmasq_interface => 'br-ctlplane', + :ramdisk_logs_dir => '/var/log/ironic-inspector/ramdisk/', + :keep_ports => 'all', + :store_data => 'none', + :ironic_auth_type => 'password', + :ironic_username => 'ironic', + :ironic_tenant_name => 'services', + :ironic_auth_url => 'http://127.0.0.1:5000/v2.0', + :ironic_max_retries => 30, + :ironic_retry_interval => 2, + :swift_auth_type => 'password', + :swift_username => 'ironic', + :swift_tenant_name => 'services', + :swift_auth_url => 'http://127.0.0.1:5000/v2.0', + :dnsmasq_ip_subnets => [{ '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' }], + :dnsmasq_local_ip => '192.168.0.1', + :ipxe_timeout => 0, + :http_port => 8088, + :tftp_root => '/tftpboot', + :http_root => '/httpboot', } end @@ -130,6 +138,21 @@ describe 'ironic::inspector' do 'require' => 'Anchor[ironic-inspector::config::begin]', 'content' => /pxelinux/, ) + is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content( + /dhcp-range=192.168.0.100,192.168.0.120,29/ + ) + 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 /tftpboot/pxelinux.cfg/default' do is_expected.to contain_file('/tftpboot/pxelinux.cfg/default').with( @@ -168,14 +191,8 @@ 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' } ], + :dnsmasq_ip_subnets => [], + :dnsmasq_ip_range => '192.168.0.100,192.168.0.120', ) end it 'should replace default parameter with new value' do @@ -205,16 +222,7 @@ describe 'ironic::inspector' do /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/ + /dhcp-range=192.168.0.100,192.168.0.120,29/ ) end it 'should contain file /var/www/httpboot/inspector.ipxe' do diff --git a/templates/inspector_dnsmasq_http.erb b/templates/inspector_dnsmasq_http.erb index 54102620..f87d3db4 100644 --- a/templates/inspector_dnsmasq_http.erb +++ b/templates/inspector_dnsmasq_http.erb @@ -1,13 +1,22 @@ port=0 interface=<%= @dnsmasq_interface %> bind-interfaces -<% if @dnsmasq_ip_subnets.is_a?(Array) -%> -<% @dnsmasq_ip_subnets.each do |s| -%> +<% @dnsmasq_ip_subnets_real.each do |s| -%> +<% if s['tag'] and s['netmask'] -%> dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,<%= s['netmask'] -%>,29 +<% elsif s['tag'] -%> +dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,29 +<% else -%> +dhcp-range=<%= s['ip_range'] -%>,29 +<% end -%> +<% if s['gateway'] -%> +<% if s['tag'] -%> dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %> +<% else -%> +dhcp-option=option:router,<%= s['gateway'] %> +<% end -%> <% end -%> <% end -%> -dhcp-range=<%= @dnsmasq_ip_range %>,29 dhcp-sequential-ip dhcp-match=ipxe,175 <% if @enable_uefi -%> diff --git a/templates/inspector_dnsmasq_tftp.erb b/templates/inspector_dnsmasq_tftp.erb index 981bb6b7..f714cd73 100644 --- a/templates/inspector_dnsmasq_tftp.erb +++ b/templates/inspector_dnsmasq_tftp.erb @@ -1,12 +1,21 @@ port=0 interface=<%= @dnsmasq_interface %> bind-interfaces -<% if @dnsmasq_ip_subnets.is_a?(Array) -%> -<% @dnsmasq_ip_subnets.each do |s| -%> +<% @dnsmasq_ip_subnets_real.each do |s| -%> +<% if s['tag'] and s['netmask'] -%> dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,<%= s['netmask'] -%>,29 +<% elsif s['tag'] -%> +dhcp-range=set:<%= s['tag'] -%>,<%= s['ip_range'] -%>,29 +<% else -%> +dhcp-range=<%= s['ip_range'] -%>,29 +<% end -%> +<% if s['gateway'] -%> +<% if s['tag'] -%> dhcp-option=tag:<%= s['tag'] -%>,option:router,<%= s['gateway'] %> +<% else -%> +dhcp-option=option:router,<%= s['gateway'] %> +<% end -%> <% end -%> <% end -%> -dhcp-range=<%= @dnsmasq_ip_range %>,29 dhcp-boot=pxelinux.0,localhost.localdomain,<%= @dnsmasq_local_ip %> dhcp-sequential-ip