Ask Your Question
0

Hiera parameter value is not received by Puppet

asked 2017-02-28 08:57:26 -0500

iong gravatar image

I'm trying to configure kerberos (using pfmooney/mit_krb5 module) and set some parameters from Hiera. The parameter is declared in Hiera as follows:

mit_krb5:
  'default_realm': 'DOMAIN.COM'

I ran the debug against the node and the correct value is return

puppet lookup --debug mit_krb5 --node server.domain.com

default_realm: DOMAIN.COM

The puppet agent fails with this error

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, defaultrealm must be set manually or via Hiera at /etc/puppetlabs/code/environments/production/modules/mitkrb5/manifests/init.pp:264:5 on node server.domain.com

This is the code from init.pp

 if $default_realm == '' {
    fail('default_realm must be set manually or via Hiera')
  }
  # END Parameter validation }

Would you please let me know why the return value for default_realm is null but when I run the debug comes back with the correct value?

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-01 06:53:09 -0500

puser gravatar image

Shot in the dark - since you are setting variables in your debug to get the data, i.e.

--debug mit_krb5 --node server.domain.com

I would make sure those same values are applying to the server running the manifests. Also can you provide the entire init.pp file?

When you are passing data in from Hiera you still need an input parameter like:

class myclass (
  $default_realm = nil,
){

if $default_realm == '' {
  fail('default_realm must be set manually or via Hiera')
}
# END Parameter validation }
}

You also need to make sure that the path in Hiera matches the path to your module. For example if your tree structure of your module was like this:

mymodule/
|-- README.md
|-- examples
|   `-- init.pp
|-- manifests
|   `-- init.pp
`-- metadata.json

Then your Hiera would look like:

---
$mymodule::default_realm: 'DOMAIN.COM'

However if your module was structures like:

mymodule/
|-- README.md
|-- examples
|   `-- init.pp
|-- manifests
|   `-- innerclass
|       `-- init.pp
`-- metadata.json

Then your hiera would look like:

---
module::innerclass::default_realm: 'DOMAIN.COM'

Hope that helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-02-28 08:57:26 -0500

Seen: 24 times

Last updated: Mar 01