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

Module Parameters Being Converted When Retreived from Hiera Data #280

Open
jcitarello-ercot opened this issue Feb 7, 2020 · 4 comments
Open

Comments

@jcitarello-ercot
Copy link

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 2018.1.8
  • Ruby:
  • Distribution:
  • Module version: 4.0.0

How to reproduce (e.g Puppet code you use)

Instead of hard coding params via a resource-like declaration, I am attempting to utilize our existing hiera structure with include-like statements.

What are you seeing

The hierarchy entries that utilize fact values are not being literallly translated to the hiera.yaml file that is created.

Ie. This is is the entry in my hiera structure....

#profile::cia::puppet_masters
hiera::hiera_version: '5'
hiera::hiera_yaml: "/usr/local/src/hiera.yaml"
hiera::hiera5_defaults:
datadir: "data"
data_hash: "yaml_data"
hiera::hierarchy:

  • name: "Hosts"
    path: "hosts/%{facts.fqdn}.yaml"

Produces the following result in the hiera.yaml that is created.

  • name: "Hosts"
    path: "hosts/dvtlccm0011.ercot.com.yaml"

What behaviour did you expect instead

I would expect the result to be:

  • name: "Hosts"
    path: "hosts/%{facts.fqdn}.yaml"

Output log

Any additional information you'd like to impart

@jcitarello-ercot
Copy link
Author

I was able to correct this with a little help from Puppet Support using the literal function in hiera.

"hosts/%{literal('%')}{facts.fqdn}.yaml" works perfectly.

@ghoneycutt
Copy link
Member

@jcitarello Thanks for posting the fix! Could you please update the README to show this in an example and call out how to access the $facts hash.

@jcitarello-ercot
Copy link
Author

@ghoneycutt Could do, but as of now I am considering if hiera may not be the best place to store and retrieve data by way of include statements and auto-lookup when creating/updating a hiera.yaml file. I mean, it is perfectly acceptable if you already have an existing hiera,yaml and data structure in place to put the parameters, but now I am considering what happens when a path to the data doesn't already exist in hiera, or worse... that path gets removed.

If nothing else, it may be prudent to note this chicken/egg situation in any updates to the readme, and I will give it a bit more thought in doing so.

@ghoneycutt
Copy link
Member

I simple PR just noting the above would certainly be useful and then we could close this out.

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

No branches or pull requests

2 participants