Vagrant failed to initialize at a very early stage:
There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.
Path: /home/ivan/dev/fapps/Vagrantfile
Message: undefined method `to_h’ for #Hash:0x000000019f1400
Everything else includeing staging server and deployment works fine.
It seems this is the code that errors out:
if File.exists?(config_file)
wordpress_sites = YAML.load_file(config_file)[‘wordpress_sites’]
raise “no sites found in #{config_file}” if wordpress_sites.to_h.empty?
else
raise "#{config_file} file not found. Please set ANSIBLE_PATH in Vagrantfile"
end
wordpress_sites seems to be empty and it isn’t, it’s set in the development config file.
Did you set the path to the ansible folder? At the top of the Vagrantfile I believe the default entry is __dir__, you should replace that with the path to the ansible folder.
I’m running out of simple suggestions, you seem to have all the obvious stuff right… it’s tempting to assume that either Vagrant can’t find the file, or the information in the file is somehow invalid, but it could be some kind of software glitch.
Maybe you could post your file/folder structure? I don’t want to waste your time with suggestions if someone else has a better idea of what might be going wrong here.
I don’t know anything about ruby, but after a quick search, I think to_h was added in Ruby 2.0. You could run ruby -v to check that you have ruby 2.0. If you’re on less than 2.0, seems like your options are
upgrade ruby
find an alternative to to_h
temporarily comment out this line in your Vagrantfile.
Vagrant uses it’s own embedded ruby. I believe that changing your local ruby version would have no effect on it.
@Ivan_Svaljek, what version of Vagrant are you using? Also, please post the full error message you get when doing the Vagrant up. You can keep the code formatted by using the code button in the editor