1

我继承了一个使用 Puppet、Vagrant 和 VirtualBox 来配置本地 Centos 测试机的 python 应用程序。

这个应用程序是在 Mac 上编写的,我正在 Windows 上开发。

当我运行时,vagrant up我看到大量命令行错误,其中最相关的是:

Running Puppet with site.pp..    
Warning: Config file /home/vagrant/hiera.yaml not found, using Hiera defaults
WARN: Fri Apr 25 16:32:24 +0100 2014: Not using Hiera::Puppet_logger. It does not report itself to b
e suitable.

我知道 Hiera 是什么,以及为什么它很重要,但我不确定如何解决这个问题。

文件 hiera.yaml 存在于 repo 中,但在home/vagrant/hiera.yaml中找不到,而是在./puppet/manifests/hiera.yaml .... 中找到。同样,如果我 ssh 进入框中,则有在home/vagrant中绝对没有任何东西,但是当我查看 /tmp 时我可以找到这个文件

所以我很困惑,是否 vagrant 正在查看虚拟框并期望在home/vagrant/hiera.yaml中找到该文件?还是我继承了一个一开始就不能正常工作的应用程序?我真的被困在这里,无法与原始开发人员取得联系。

以下是我的 Vagrantfile 中的一些详细信息:

Vagrant.configure("2") do |config|
  # Base box configuration ommitted    
  # Forwarded ports ommitted   
  # Statically set hostname and internal network to match puppet env ommitted

  # Enable provisioning with Puppet standalone 
  config.vm.provision :puppet do |puppet|

    # Tell Puppet where to find the hiera config
    puppet.options = "--hiera_config hiera.yaml --manifestdir /tmp/vagrant-puppet/manifests"

    # Boilerplate Vagrant/Puppet configuration
    puppet.module_path = "puppet/modules"
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file = "site.pp"

    # Custom facts provided to Puppet
    puppet.facter = {
      # Tells Puppet that we're running in Vagrant
      "is_vagrant" => true,
    }
  end

  # Make the client accessible
  config.vm.synced_folder "marflar_client/", "/opt/marflar_client"
end

这真的很奇怪。

4

2 回答 2

2

有这一puppet.options行告诉 Puppet 在哪里寻找 hiera.yaml,目前它只是指定文件名。现在,当您运行时vagrant up,它会将当前目录(其中包含该目录的目录Vagrantfile)安装到/vagrant来宾计算机上。既然您说hiera.yaml的实际上是在 中找到的./puppet/manifests/hiera.yaml,我相信您想puppet.options按如下方式更改该行:

puppet.options = "--hiera_config /vagrant/puppet/manifests/hiera.yaml --manifestdir /tmp/vagrant-puppet/manifests"
于 2014-04-26T19:10:20.973 回答
0

To solve this warning, you may first try to check from where this file is referenced, i.e.:

$ grep -Rn hiera.yaml /etc/puppet
/etc/puppet/modules/stdlib/spec/spec_helper_acceptance.rb:13:    on hosts, '/bin/touch /etc/puppet/hiera.yaml'
/etc/puppet/modules/mysql/spec/spec_helper_acceptance.rb:34:      shell("/bin/touch #{default['puppetpath']}/hiera.yaml")

In this case it's your vagrant file.

You may also try to find the right path to it via:

sudo updatedb && locate hiera.yaml

And either follow the @EvgenyChernyavskiy suggestion, create a symbolic link if you found the file:

sudo ln -vs /etc/hiera.yaml /etc/puppet/hiera.yaml

or create the empty file (touch /etc/puppet/hiera.yaml).

In your case you should use the absolute path to your hiera.yaml file, instead of relative.

The warning should be gone.

于 2014-10-02T12:37:21.957 回答