2017-03-24 42 views
1

我想知道我需要在我的yaml文件中使hiera輸出字符串%{::fqdn}而不是輸出傀儡事實fqdn的值。如何讓hiera輸出字符串'%{:: fqdn}'?

這是我試過的。

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

這是結果:

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

我真正想要的輸出爲是:

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

我想我可以做這樣的事情愚蠢:

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

然後輸出是什麼我想:

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

回答

1

按照documentation

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