Puppet

Puppet::Environments::EnvironmentNotFound 當文件夾存在時

  • May 2, 2020

我的 puppet 主伺服器上有 2 個環境的文件結構。ls /etc/puppetlabs/code/environments/在我的主伺服器上執行會返回兩個文件夾betaproduction.

然而,當我繼續我的代理並執行時,puppet apply -t --environment beta我得到了錯誤:

/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/environments.rb:38:in `get!':
Could not find a directory environment named 'beta' anywhere in the path: /etc/puppetlabs/code/environments.
Does the directory exist? (Puppet::Environments::EnvironmentNotFound)

在主伺服器上,我可以成功地使用puppet apply /etc/puppetlabs/code/environments/beta/manifests/site.pp.

我試圖弄清楚為什麼 Puppet 沒有檢測到該文件夾。我該如何調試呢?

正如@gd_ 所建議的那樣,我也嘗試puppet agent -t --environment beta了,它返回:

注意:本地環境:“beta”與伺服器指定的節點環境“production”不匹配,將代理切換到“production”。

/etc/puppetlabs/puppet/puppet.conf(代理)如下:

# This file can be used to override the default puppet settings.
# See the following links for more details on what settings are available:
# - https://docs.puppetlabs.com/puppet/latest/reference/config_important_settings.html
# - https://docs.puppetlabs.com/puppet/latest/reference/config_about_settings.html
# - https://docs.puppetlabs.com/puppet/latest/reference/config_file_main.html
# - https://docs.puppetlabs.com/puppet/latest/reference/configuration.html

使用開源版本。

使用puppet agent ..., 而不是puppet apply .... 您使用的參數適用於前者,而不是後者。

另一種選擇是在代理的**/etc/hosts**hostname中 - 伺服器的名稱與命令結果中顯示的不一樣, 當代理與 puppet 伺服器通信時,這可能會導致混淆

引用自:https://serverfault.com/questions/848522