Override Vagrant configuration settings locally (per-dev)

前端 未结 8 1285
说谎
说谎 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:48

    I would suggest using environment variables to dynamically change the behavior of the Vagrantfile without editing the file itself.

    To give a real world example, here's how you could use an Ubuntu base box by default but have an environment variable define an alternative Linux distribution:

    if ENV['OPERATINGSYSTEM']
      if ENV['OPERATINGSYSTEM'].downcase == 'redhat'
        os_name = 'centos'
        config.vm.box     = 'centos'
        config.vm.box_url = 'https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box'
      else
        raise(Exception, "undefined operatingsystem: #{ENV['OPERATINGSYSTEM']}")
      end
    else
      os_name = 'precise64'
      config.vm.box     = 'precise64'
      config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
    end
    

    This example comes from https://github.com/puppetlabs/puppetlabs-openstack_dev_env

提交回复
热议问题