2017-05-31 35 views
0

我會嘗試在epp模板中使用$ server_facts ['environment'],但他不工作正確。 我EPP代碼:epp模板中的[Puppet]環境變量

<% if $::facts[environment] == 'production' { -%> 
# this is production server 
<% } else { -%> 
# this is NOT production server 
<% } -%> 

代碼運行沒有錯誤,但總是用部分else後。請幫助解決它。

+0

打印出模板的當前值:'<%= $ ::事實[環境]%>'。另外,它是server_facts還是你想要的事實? –

+0

1)變量返回空值 2)server_facts(來自puppet.conf的值) – beliy

回答

1

使用$::facts[agent_specified_environment]畢竟做工精細:

<% if $::facts[agent_specified_environment] == 'production' { -%> 
# this is production server 
<% } else { -%> 
# this is NOT production server 
<% } -%>