# Revision history [back]

### How do I get this hiera hash lookup to work properly?

I am using a Hiera hash to hold some token values which are host-specific. the keys within the hash correspond to the hostname/certname of the node(s) that'll be classified with the profile module that calls the hash value. However, when I apply the module, the value which corresponds to the hash key for the host is always null. Here's the code I'm working with.

in hiera-file.yaml

token_lookup:
hostname1: 'abcdef123'
hostname2: 'abbcde456'


and in profile.pp

$_tokens = hiera_hash('token_lookup', undef, 'hiera-file')$_specific_token = $_tokens["${::hostname}"]       <== never gets a value


I'm certain that the hostname matches the key in the hash. The question is, what's the right syntax here for getting the value from the hiera-file to populate properly? Thank you in advance for the advice.

### How do I get this hiera hash lookup to work properly?

I am using a Hiera hash to hold some token values which are host-specific. the keys within the hash correspond to the hostname/certname of the node(s) that'll be classified with the profile module that calls the hash value. However, when I apply the module, the value which corresponds to the hash key for the host is always null. Here's the code I'm working with.

in hiera-file.yaml

token_lookup:
hostname1: host-name1: 'abcdef123'
hostname2: host-name2: 'abbcde456'


and in profile.pp

$_tokens = hiera_hash('token_lookup', undef, 'hiera-file')$_specific_token = $_tokens["${::hostname}"]       <== never gets a value


I'm certain that the hostname matches the key in the hash. The question is, what's the right syntax here for getting the value from the hiera-file to populate properly? Thank you in advance for the advice.

edit: I think I've narrowed the issue to the notion that the hostnames have dashes/hyphens in them. Quoting the keys doesn't seem to provide the same benefit that quoting a value does for escape-needed characters. I didn't think the literal dash mattered, and it passes YAML lint/syntax checks, but even in canonical YAML format I can't get the lookup to match the hostname. Looking now more specifically for advice on escaping characters in the key