簡體   English   中英

人偶-不建議使用函數“ hiera_array”,而建議使用“查找”

[英]Puppet - The function 'hiera_array' is deprecated in favor of using 'lookup'

我有一個人偶問題。 (我正在使用5.1.0版本)

在此路徑中:C:\\ ProgramData \\ PuppetLabs \\ code \\ environments \\ production \\ manifests我有以下文件:site.pp該文件(/etc/puppetlabs/puppet/manifests/site.pp)是在代理連接到主服務器,並要求更新配置。

現在是文件的內容:

node default {
  # This is where you can declare classes for all nodes.
  # Example:
  #   class { 'my_class': }
  #hiera_include('classes')
  include(hiera_array("classes", ))
}

但是當我使用puppet apply命令運行puppet時,它是:

“ C:\\ Program Files \\ Puppet Labs \\ Puppet \\ bin \\ puppet”應用C:\\ ProgramData \\ PuppetLabs \\ code \\ environments \\ production \\ manifests \\ site.pp

我收到此錯誤:

 Warning: The function 'hiera_array' is deprecated in favor of using 'lookup'. See https://docs.puppet.com/puppet/5.1/referenc e/deprecated_language.html (file & line not available) Error: Function lookup() did not find a value for the name 'classes' 

所以我將site.pp代碼更改為:

node default {
  # This is where you can declare classes for all nodes.
  # Example:
  #   class { 'my_class': }
  #hiera_include('classes')
  include(lookup('classes', {merge => unique}, ))
}

(因為我找到了此文檔: https : //puppet.com/docs/puppet/5.1/hiera_migrate_functions.html

現在我只得到這個錯誤:

 Error: Function lookup() did not find a value for the name 'classes' 

我不確定如何解決它,因為該代碼在一個月前使用相同的apply命令起作用。

你能幫我么?

謝謝!

我收到此錯誤:

 Warning: The function 'hiera_array' is deprecated in favor of using 'lookup'. See https://docs.puppet.com/puppet/5.1/referenc e/deprecated_language.html (file & line not available) Error: Function lookup() did not find a value for the name 'classes' 

更正:您收到警告錯誤。 該錯誤是單獨的,但表明Puppet正在內部委派新的lookup()函數來處理警告的情況。

所以我將site.pp代碼更改為:

 node default { # This is where you can declare classes for all nodes. # Example: # class { 'my_class': } #hiera_include('classes') include(lookup('classes', {merge => unique}, )) } 

是的,這是解決警告的一種非常好的自然方法,而且看起來很成功。 但是同樣,錯誤是單獨的。 這與清單無關,而與數據有關 如它所說,查找關鍵“類”的嘗試失敗了。 找不到這樣的密鑰。 在這種情況下,您沒有提供具有默認值的lookup()來返回,因此會發生錯誤。

我不確定如何解決它,因為該代碼在一個月前使用相同的apply命令起作用。

如果Puppet曾經運行相同的代碼而沒有發出錯誤,則從那時到現在的變化是數據。 但是,可能是因為您現在以其他用戶身份運行Puppet。 不同的普通用戶都有自己的默認數據(和清單)位置,並且這些都與系統運行Puppet時使用的位置不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM