问题
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}
回答1:
According to the documentation:
foo:p4: 'http://%{literal(''%'')}{hiera(''p1'')}/%{literal(''%'')}{::fqdn}'
来源:https://stackoverflow.com/questions/43005412/how-to-get-hiera-to-output-the-literal-string-fqdn