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

The has_ip_address function no longer works #1447

Open
erncode opened this issue Feb 7, 2025 · 1 comment · May be fixed by #1448
Open

The has_ip_address function no longer works #1447

erncode opened this issue Feb 7, 2025 · 1 comment · May be fixed by #1448

Comments

@erncode
Copy link

erncode commented Feb 7, 2025

Describe the Bug

When performing a Puppet agent run, the following is reported.
"Error while evaluating a Function Call, Undefined variable 'interfaces'"
The location described by the error refers to a line that runs the "has_ip_address" function. Previously this worked on PE 2021 and Puppet Agent 7.30.0

Expected Behavior

The function should check if an IP address is on the local server and return true or false.

Steps to Reproduce

puppet agent -t

Environment

"name": "puppetlabs-stdlib",
"version": "9.7.0",
"os": RedHat 7.9
"puppet enterprise": 2023.8.1
"puppet agent": 8.10.0

Additional Context

I'm guessing this is because the "interfaces" fact no longer exists, as confirmed by the "facter -p" command. OpenSource Puppet also refers to "interfaces" as a legacy fact - https://www.puppet.com/docs/puppet/7/core_facts.htm

@alexjfisher
Copy link
Collaborator

This function is still a 'legacy' (pre puppet 4 API) style function. As such, when it calls has_interface_with, it calls the legacy implementation of this function instead of the modern and fixed one from #1326

alexjfisher added a commit to alexjfisher/puppetlabs-stdlib that referenced this issue Feb 11, 2025
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 linked a pull request Feb 11, 2025 that will close this issue
alexjfisher added a commit to alexjfisher/puppetlabs-stdlib that referenced this issue Feb 11, 2025
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
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 a pull request may close this issue.

2 participants