Skip to content
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

Fix has_ip_address and has_ip_network functions #1448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexjfisher
Copy link
Collaborator

The functions were using the old legacy function API. This meant that when they called has_interface_with, they were calling the legacy implementation of that function and not the v4 API version introduced in bc218f0.

Only in the v4 API implementation was the modern networking structured fact being used. The old parser/functions/has_interface_with.rb version still used legacy facts that are now not included in Puppet 8 by default.

In this commit, we replace the has_ip_address and has_ip_network functions with namespaced Puppet language functions, (these functions are simple enough to not need ruby). Non-namespaced versions are added (but marked as deprecated) in lib/puppet/functions.

The old implementations are removed completely. This is almost certainly not going to be a breaking change for anyone. (Only other legacy functions which in turn call these functions could be affected).

Fixes #1447

The functions were using the old legacy function API.  This meant that
when they called `has_interface_with`, they were calling the legacy
implementation of that function and not the v4 API version introduced in
bc218f0.

Only in the v4 API implementation was the modern `networking` structured
fact being used.  The old `parser/functions/has_interface_with.rb`
version still used legacy facts that are now not included in Puppet 8 by
default.

In this commit, we replace the `has_ip_address` and `has_ip_network`
functions with namespaced Puppet language functions, (these functions
are simple enough to not need ruby). Non-namespaced versions are added
(but marked as deprecated) in `lib/puppet/functions`.

The old implementations are removed completely. This is _almost_
certainly not going to be a breaking change for anyone. (Only other
legacy functions which in turn call these functions could be affected).

Fixes puppetlabs#1447
@alexjfisher alexjfisher marked this pull request as ready for review February 11, 2025 21:40
@@ -0,0 +1,10 @@
# @summary Returns true if the client has the requested IPv4 address on some interface.
#
# @param ip_address
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also support ipv6?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone wants to add that, they could open a PR for it. I did have a quick think about it, and I guess with IPv6 you'd want to do something a bit more sophisticated than just matching the string though as there are several ways to write the same address.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that would require updating stdlib::has_interface_with() to work with IpAddr objects

@Henrik-Hansson
Copy link

I think the acceptance test breaks due to puppetlabs/puppetlabs-puppet_agent#754.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The has_ip_address function no longer works
4 participants