Search code examples
vagrantpuppetvagrantfile

Vagrant not able to find home/vagrant/hiera.yaml


I have inherited a python app that uses Puppet, Vagrant and VirtualBox to provision a local Centos test machine.

This app was written on Mac and I'm developing on Windows.

When I run vagrant up I see a large list of command line errors, the most relevant of which is:

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.

I know what Hiera is, and why it's important, but I'm not sure how to fix this.

The file hiera.yaml is present in the repo but it's not found at home/vagrant/hiera.yaml, instead it's found at ./puppet/manifests/hiera.yaml.... Similarly if I ssh into the box, there is absolutely nothing whatsoever inside home/vagrant but I can find this file when I look in /tmp

So I'm confused, is vagrant looking inside the Virtual box and expecting this file to be found at home/vagrant/hiera.yaml? Or have I inherited an app that did not work properly in the first place? I'm really stuck here and I can't get in touch with the original dev.

Here are some details from my 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

It's really strange.


Solution

  • There's this puppet.options line that tells Puppet where to look for hiera.yaml and currently it simply specifies the file name. Now, when you run vagrant up, it mounts the current directory (the one that has the Vagrantfile in it) into /vagrant on the guest machine. Since you're saying hiera.yaml is actually found in ./puppet/manifests/hiera.yaml, I believe you want to change the puppet.options line as follows:

    puppet.options = "--hiera_config /vagrant/puppet/manifests/hiera.yaml --manifestdir /tmp/vagrant-puppet/manifests"