Override Vagrant configuration settings locally (per-dev)

前端 未结 8 1471
说谎
说谎 2021-01-30 02:51

I\'d like the question to be answered in general, but to illustrate it, here\'s a use case:

I\'m using Vagrant for a simple LMAP project. I use standalone Puppet for pro

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 03:40

    You can load the settings from YAML file. This is demonstrated in Drupal VM as below:

    # Use config.yml for basic VM configuration.
    require 'yaml'
    dir = File.dirname(File.expand_path(__FILE__))
    if !File.exist?("#{dir}/config.yml")
      raise 'Configuration file not found! Please copy example.config.yml to config.yml and try again.'
    end
    vconfig = YAML::load_file("#{dir}/config.yml")
    

    So then you can create config.yml like:

    vagrant_box: geerlingguy/ubuntu1404
    vagrant_user: vagrant
    vagrant_ip: 192.168.88.88
    

    and in Vagrantfile you can use variables as:

    config.vm.box = vconfig['vagrant_box']
    config.vm.network "private_network", ip: vconfig['vagrant_ip']
    

提交回复
热议问题