New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #21114 - Update error message #375
Conversation
@chris1984, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:
If changing the ticket number used, remember to update the PR title and the commit message (using This message was auto-generated by Foreman's prprocessor |
manifests/proxydhcp.pp
Outdated
@@ -3,7 +3,7 @@ | |||
# 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}') %>")) | |||
$ip = pick_default($::foreman_proxy::dhcp_pxeserver, inline_template("<%= scope.lookupvar('::ipaddress_${interface_fact_name}', '') %>"), '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should depend on puppetlabs-stdlib 4.19.0 already since it's very new, but with that it can be $ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}"))
.
@ekohl thanks, fixed with the correction, can you look at it when you get another chance please? |
👍 |
Could you add a testcase? Untested, but something adding the following to context "on a non-existing interface" do
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 You should also increase the puppetlabs-stdlib minimum version to 4.19.0 in |
@ekohl thanks for the help with the tests and the corrections, I have made the requested changes. Can you review when you get a chance, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some minor style tweaks would be nice.
@@ -183,6 +183,16 @@ | |||
}" | |||
end | |||
|
|||
context "on a non-existing interface" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indenting looks inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked in Atom and it at spot 7 and the other contexts are as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you pasted in the middle of another context. That's why the indenting looks incorrect.
manifests/proxydhcp.pp
Outdated
@@ -3,7 +3,7 @@ | |||
# 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}') %>")) | |||
$ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}")) | |||
if ! is_ip_address($ip) { | |||
fail("Could not get the ip address from fact ipaddress_${interface_fact_name}") | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just below the fold here we have more inline_template
use. Could you also replace those with fact
to keep it consistent?
manifests/proxydhcp.pp
Outdated
@@ -3,7 +3,7 @@ | |||
# 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}') %>")) | |||
$ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}")) | |||
if ! is_ip_address($ip) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, mind replacing this with the non-deprecated version to remove a deprecation warning? I think unless $ip =~ Stdlib::Compat::Ipv4 {
should work. Same for the other 3 occurrences.
@ekohl can I get another review please, also see the comment about the indenting. |
manifests/proxydhcp.pp
Outdated
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("<%= scope.lookupvar('::network_${interface_fact_name}') %>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fact("network_${interface_fact_name}")
manifests/proxydhcp.pp
Outdated
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("<%= scope.lookupvar('::netmask_${interface_fact_name}') %>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
@ekohl the tests are failing since it cant find the ip, do i need to update the tests as well, I made the changes you suggested. |
merged, thanks @chris1984! |
No description provided.