From f291aa33fbb6cef2428fd55fd2a23e52622fca0d Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 29 Sep 2017 15:01:39 -0400 Subject: [PATCH] Fixes #21114 - Update error message --- manifests/proxydhcp.pp | 12 ++++++------ metadata.json | 2 +- spec/classes/foreman_proxy__proxydhcp__spec.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifests/proxydhcp.pp b/manifests/proxydhcp.pp index f389ad9f..a8e063cd 100644 --- a/manifests/proxydhcp.pp +++ b/manifests/proxydhcp.pp @@ -3,18 +3,18 @@ # puppet fact names are converted from ethX.X and ethX:X to ethX_X # so for alias and vlan interfaces we have to modify the name accordingly $interface_fact_name = regsubst($foreman_proxy::dhcp_interface, '[.:]', '_') - $ip = pick($::foreman_proxy::dhcp_pxeserver, inline_template("<%= scope.lookupvar('::ipaddress_${interface_fact_name}') %>")) - if ! is_ip_address($ip) { + $ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}")) + unless ($ip =~ Stdlib::Compat::Ipv4) { fail("Could not get the ip address from fact ipaddress_${interface_fact_name}") } - $net = inline_template("<%= scope.lookupvar('::network_${interface_fact_name}') %>") - if ! is_ip_address($net) { + $net = fact("network_${interface_fact_name}") + unless ($ip =~ Stdlib::Compat::Ipv4) { fail("Could not get the network address from fact network_${interface_fact_name}") } - $mask = inline_template("<%= scope.lookupvar('::netmask_${interface_fact_name}') %>") - if ! is_ip_address($mask) { + $mask = fact("netmask_${interface_fact_name}") + unless ($ip =~ Stdlib::Compat::Ipv4) { fail("Could not get the network mask from fact netmask_${interface_fact_name}") } diff --git a/metadata.json b/metadata.json index 4f1b53cd..f0b21a02 100644 --- a/metadata.json +++ b/metadata.json @@ -40,7 +40,7 @@ }, { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.13.0 < 5.0.0" + "version_requirement": ">= 4.19.0 < 5.0.0" }, { "name": "puppet/extlib", diff --git a/spec/classes/foreman_proxy__proxydhcp__spec.rb b/spec/classes/foreman_proxy__proxydhcp__spec.rb index 6749467d..7ca6c3cd 100644 --- a/spec/classes/foreman_proxy__proxydhcp__spec.rb +++ b/spec/classes/foreman_proxy__proxydhcp__spec.rb @@ -195,6 +195,20 @@ ) end end + context "on a non-existing interface" do + let :facts do + facts + end + + let :pre_condition do + "class { 'foreman_proxy': + dhcp_interface => 'doesnotexist', + }" + end + + it { should raise_error(Puppet::Error, /Could not get the ip address from fact ipaddress_doesnotexist/) } + end + context "as manager of ACLs for dhcp" do let :facts do facts.merge({:ipaddress_eth0 => '192.168.100.20',