How do I include variables in my VagrantFile?

I use the approach of https://puphpet.com, I create a file config.yaml in the same directory of the Vagrantfile and…

In my Vagrantfile:

# encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'yaml'

current_dir    = File.dirname(File.expand_path(__FILE__))
configs        = YAML.load_file("#{current_dir}/config.yaml")
vagrant_config = configs['configs'][configs['configs']['use']]

Vagrant.configure('2') do |config|

    config.vm.network 'public_network', ip: vagrant_config['public_ip']
    ...

In my config.yaml:

---
configs:
    use: 'home'
    office:
        public_ip: '192.168.2.117'
        <more variables>...
    home:
        public_ip: '192.168.1.117'
        <more variables>...

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)