From 66119406b0b87e3aeced955a233d62cb329d612b Mon Sep 17 00:00:00 2001 From: Jan Vansteenkiste Date: Thu, 26 Jul 2018 10:31:19 +0200 Subject: [PATCH] Debian default ipv4 interfaces config has changed Since stretch, the /etc/default/isc-dhcp-server entry for the interfaces to listen on has changed to INTERFACESv4. This change reflects that. Fixes #177 and closes #185 --- spec/classes/dhcp_spec.rb | 37 ++++++++++++++++++++++-- templates/debian/default_isc-dhcp-server | 9 +++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/spec/classes/dhcp_spec.rb b/spec/classes/dhcp_spec.rb index 640a86c17..7af31a484 100644 --- a/spec/classes/dhcp_spec.rb +++ b/spec/classes/dhcp_spec.rb @@ -465,13 +465,21 @@ let :default_facts do { osfamily: 'Debian', - concat_basedir: '/dne' + concat_basedir: '/dne', } end - context 'Debian' do + context 'Debian < 9' do let :facts do - default_facts.merge(operatingsystem: 'Debian', os: { family: 'Debian' }) + default_facts.merge( + os: { + name: 'Debian', + family: 'Debian', + release: { + major: 8, + }, + } + ) end let :params do default_params.merge(interface: 'eth0') @@ -484,6 +492,29 @@ with_content(%r{INTERFACES=\"eth0\"}) end end + context 'Debian > 9' do + let :facts do + default_facts.merge( + os: { + name: 'Debian', + family: 'Debian', + release: { + major: 9, + }, + } + ) + end + let :params do + default_params.merge(interface: 'eth0') + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_package('isc-dhcp-server') } + it do + is_expected.to contain_file('/etc/default/isc-dhcp-server'). \ + with_content(%r{INTERFACESv4=\"eth0\"}) + end + end context 'Ubuntu' do let :params do default_params.merge(interface: 'eth0') diff --git a/templates/debian/default_isc-dhcp-server b/templates/debian/default_isc-dhcp-server index b32122556..a3ac47a41 100644 --- a/templates/debian/default_isc-dhcp-server +++ b/templates/debian/default_isc-dhcp-server @@ -8,4 +8,11 @@ # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". -INTERFACES="<%= Array(@dhcp_interfaces).join(' ') %>" +<% + if @facts['os']['name'] == 'Debian' && @facts['os']['release']['major'] >= 9 + interfaces_key = 'INTERFACESv4' + else + interfaces_key = 'INTERFACES' + end +%> +<%= interfaces_key %>="<%= Array(@dhcp_interfaces).join(' ') %>"