【问题标题】:Vagrant not able to find home/vagrant/hiera.yamlVagrant 找不到 home/vagrant/hiera.yaml
【发布时间】:2014-10-02 20:37:21
【问题描述】:

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

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

当我运行vagrant up 时,我看到一大串command line errors,其中最相关的是:

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 中找到它/em>.... 同样,如果我 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

真的很奇怪。

【问题讨论】:

    标签: vagrant puppet vagrantfile


    【解决方案1】:

    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"
    

    【讨论】:

    • 可能值得注意的是 hiera_config 选项仅在 Puppet 3 中可用。*
    • 非常感谢,这个答案帮助我走得更远!太棒了。
    【解决方案2】:

    要解决此警告,您可以先尝试检查此文件的引用位置,即:

    $ 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")
    

    在这种情况下,它是您的 vagrant 文件。

    您也可以尝试通过以下方式找到正确的路径:

    sudo updatedb && locate hiera.yaml
    

    如果您找到该文件,请按照@EvgenyChernyavskiy 的建议创建一个符号链接:

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

    或创建空文件 (touch /etc/puppet/hiera.yaml)。

    在您的情况下,您应该使用 hiera.yaml 文件的绝对路径,而不是相对路径。

    警告应该消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-16
      • 2016-06-13
      • 2019-03-04
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 2016-02-28
      • 1970-01-01
      相关资源
      最近更新 更多