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

Puppet Fails to Resolve Hostname Using ${hostname}\ and any other Variable in Source Path #9500

Closed
banafshehft opened this issue Oct 15, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@banafshehft
Copy link

Describe the Bug

I am encountering an issue with Puppet where the ${hostname} variable is not resolving correctly in the source path of a file resource. The following manifest snippet is intended to retrieve a certificate file based on the system hostname:

file { '/etc/ssl/certs/Certname':
  source => "puppet:///modules/arch/vault-certs/${hostname}.Certname",
  mode   => '0644',
}

However, this results in a 404 Not Found error, as Puppet is not expanding the ${hostname} variable correctly, leading to it searching for an incorrect file name.

Expected Behavior

expected Puppet to resolve the ${hostname} variable correctly and construct the appropriate source path to retrieve the certificate file.

I have to mention it is a bug in the puppet version : puppet 8.9.0-4

Environment

  • puppet 8.9.0-4
  • Platform : linux 6.11.3.arch1-1

Additional Context

Could you please provide a temporary solution to the issue at hand, at least until we can implement a permanent fix? Thank you

@banafshehft banafshehft added the bug Something isn't working label Oct 15, 2024
@banafshehft
Copy link
Author

i should mention it seems fact works fine : facter hostname gives me the correct value
i also tried to use fact in my puppet code like this : $::hostname didnt help

@banafshehft
Copy link
Author

i also tried this as puppet says :
source => "puppet:///modules/arch/vault-certs/$facts['networking']['hostname'].Cername
still fails with tons of errors

@joshcooper
Copy link
Contributor

Hi @banafshehft Puppet 8 agents no longer send legacy facts, like hostname, to the server, see https://www.puppet.com/blog/puppet-8 for more details. You'll need to modify your manifest to reference the structured fact. Recommend running puppet-lint to validate your code. Rather than discussing this in the issue tracker, I recommend reaching out in the puppetcommunity slack. Lots of folks there can get you pointed in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants