inspector: Fix missing new line in dnsmasq.conf with multiple subnets

... and make pattern match for inspector dnsmasq.conf more
strict to  detect missing new lines or unnecessary elements.

Closes-Bug: #2042526
Change-Id: I03abeb7c1519f5a2cbcddaa3722d4053eab3566f
(cherry picked from commit e1a89eb585)
(cherry picked from commit 5d73c1aa1c)
(cherry picked from commit c968ac85a0)
This commit is contained in:
Takashi Kajinami 2023-11-02 13:24:58 +09:00
parent 92bfd718f4
commit e5dc24d158
3 changed files with 30 additions and 30 deletions

View File

@ -136,40 +136,40 @@ describe 'ironic::inspector' do
'content' => /pxelinux/,
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-range=192.168.0.100,192.168.0.120,10m/
/^dhcp-range=192.168.0.100,192.168.0.120,10m$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option-force=option:mtu,1350/
/^dhcp-option-force=option:mtu,1350$/
)
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,10m/
/^dhcp-range=set:subnet1,192.168.1.100,192.168.1.200,255.255.255.0,10m$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:subnet1,option:router,192.168.1.254/
/^dhcp-option=tag:subnet1,option:router,192.168.1.254$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option-force=tag:subnet1,option:mtu,1350/
/^dhcp-option-force=tag:subnet1,option:mtu,1350$/
)
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,10m/
/^dhcp-range=set:subnet2,192.168.2.100,192.168.2.200,255.255.255.0,10m$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:subnet2,option:router,192.168.2.254/
/^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/
/^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$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-range=set:subnet3,2001:4888:a03:313a:c0:fe0:0:c200,2001:4888:a03:313a:c0:fe0:0:c2ff,64,10m/
/^dhcp-range=set:subnet3,2001:4888:a03:313a:c0:fe0:0:c200,2001:4888:a03:313a:c0:fe0:0:c2ff,64,10m$/
)
is_expected.not_to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:subnet3,option:router,2001:4888:a03:313a:c0:fe0:0:c000/
/^dhcp-option=tag:subnet3,option:router,2001:4888:a03:313a:c0:fe0:0:c000$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-sequential-ip/
/^dhcp-sequential-ip$/
)
is_expected.not_to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/log-facility=.*/
/^log-facility=.*$/
)
end
it 'should contain file /tftpboot/pxelinux.cfg/default' do
@ -230,34 +230,34 @@ describe 'ironic::inspector' do
'content' => /ipxe/,
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-boot=tag:ipxe,http:\/\/192.168.0.1:3816\/inspector.ipxe/
/^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=192.168.0.100,192.168.0.120,10m/
/^dhcp-range=192.168.0.100,192.168.0.120,10m$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/log-dhcp/
/^log-dhcp$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/log-queries/
/^log-queries$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-userclass=set:ipxe6,iPXE/
/^dhcp-userclass=set:ipxe6,iPXE$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:ipxe6,option6:bootfile-url,http:\/\/.*:3816\/inspector.ipxe/
/^dhcp-option=tag:ipxe6,option6:bootfile-url,http:\/\/.*:3816\/inspector.ipxe$/
)
is_expected.not_to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-sequential-ip/
/^dhcp-sequential-ip$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/log-facility=\/var\/log\/ironic-inspector\/dnsmasq.log/
/^log-facility=\/var\/log\/ironic-inspector\/dnsmasq.log$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-boot=tag:efi,tag:!ipxe,otherpxe.efi/
/^dhcp-boot=tag:efi,tag:!ipxe,otherpxe.efi$/
)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-option=tag:efi6,tag:!ipxe6,option6:bootfile-url,tftp:\/\/.*\/otherpxe.efi/
/^dhcp-option=tag:efi6,tag:!ipxe6,option6:bootfile-url,tftp:\/\/.*\/otherpxe.efi$/
)
end
@ -315,8 +315,8 @@ describe 'ironic::inspector' do
end
it 'should contain file /etc/ironic-inspector/dnsmasq.conf' do
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-match=set:ppc64le,option:client-arch,14/)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/^dhcp-match=set:ppc64le,option:client-arch,14$/)
end
it 'should contain directory /tftpboot/ppc64le with selinux type tftpdir_t' do
is_expected.to contain_file('/tftpboot/ppc64le').with(
@ -355,8 +355,8 @@ describe 'ironic::inspector' do
end
it 'should contain file /etc/ironic-inspector/dnsmasq.conf' do
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/dhcp-match=set:ppc64le,option:client-arch,14/)
is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content(
/^dhcp-match=set:ppc64le,option:client-arch,14$/)
end
it 'should contain file /tftpboot/ppc64le/default' do
is_expected.to contain_file('/tftpboot/ppc64le/default').with(

View File

@ -35,9 +35,9 @@ dhcp-option-force=option:mtu,<%= s['mtu'] %>
<%- @_routes << route['destination'] + ',' + route['nexthop'] -%>
<% end -%>
<% if s['tag'] -%>
dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') -%>
dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') %>
<% else -%>
dhcp-option=option:classless-static-route,<%= @_routes.join(',') -%>
dhcp-option=option:classless-static-route,<%= @_routes.join(',') %>
<% end -%>
<% end -%>
<% end -%>

View File

@ -35,9 +35,9 @@ dhcp-option-force=option:mtu,<%= s['mtu'] %>
<%- @_routes << route['destination'] + ',' + route['nexthop'] -%>
<% end -%>
<% if s['tag'] -%>
dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') -%>
dhcp-option=tag:<%= s['tag'] -%>,option:classless-static-route,<%= @_routes.join(',') %>
<% else -%>
dhcp-option=option:classless-static-route,<%= @_routes.join(',') -%>
dhcp-option=option:classless-static-route,<%= @_routes.join(',') %>
<% end -%>
<% end -%>
<% end -%>