Search code examples
yamlhiera

How to get hiera to output the literal string '%{::fqdn}'?


I would like to know what I would need to have in my yaml file to have hiera output the literal string %{::fqdn} instead of outputting the value of the puppet fact fqdn.

Here is what I have tried.

# grep foo::p4 /etc/puppetlabs/code/environments/production/hieradata/bar.yaml
foo::p4: 'http://%{hiera(''p1'')}/%{::fqdn}'

And this is the result:

# hiera foo::p4 '::prefix_fact=bar' '::fqdn=thing.com' environment=production
http://test/thing.com

What I actually want the output to be is:

http://%{hiera('p1')}/%{::fqdn}

I guess I could do something goofy like this:

p1: 'test'
pa: '%{hiera'
pb: '("p1")}'
pc: '%{::fq'
pd: 'dn}'
foo::p4: "%{hiera('pa')}%{hiera('pb')}%{hiera('pc')}%{hiera('pd')}"

Then the output is what I want:

# hiera foo::p4 '::prefix=bar' '::fqdn=thing.com' environment=production
%{hiera("p1")}%{::fqdn}

Solution

  • According to the documentation:

    foo:p4: 'http://%{literal(''%'')}{hiera(''p1'')}/%{literal(''%'')}{::fqdn}'