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

蹲街弑〆低调 提交于 2019-12-11 07:59:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!