| OLD | NEW |
| 1 require 'yaml' | 1 require 'yaml' |
| 2 | 2 |
| 3 VAGRANTFILE_API_VERSION = "2" | 3 VAGRANTFILE_API_VERSION = "2" |
| 4 REPOSITORY_DIR = File.dirname(__FILE__) | 4 REPOSITORY_DIR = File.dirname(__FILE__) |
| 5 DEPENDENCY_SCRIPT = File.join(REPOSITORY_DIR, "ensure_dependencies.py") | 5 DEPENDENCY_SCRIPT = File.join(REPOSITORY_DIR, "ensure_dependencies.py") |
| 6 | 6 |
| 7 if !system("python", DEPENDENCY_SCRIPT) | 7 if !system("python", DEPENDENCY_SCRIPT) |
| 8 error = Vagrant::Errors::VagrantError | 8 error = Vagrant::Errors::VagrantError |
| 9 error.error_message("Failed to ensure dependencies being up-to-date!") | 9 error.error_message("Failed to ensure dependencies being up-to-date!") |
| 10 raise error | 10 raise error |
| 11 end | 11 end |
| 12 | 12 |
| 13 def define_standard_vm(config, host_name, ip, role=nil) | 13 def define_standard_vm(config, host_name, ip, role=nil) |
| 14 config.vm.define host_name do |config| | 14 config.vm.define host_name do |config| |
| 15 config.vm.box = 'precise64' | 15 if host_name == 'server10' |
| 16 config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/current/
precise-server-cloudimg-amd64-vagrant-disk1.box' | 16 config.vm.box = 'precise64_docker' |
| 17 config.vm.box_url = 'http://nitron-vagrant.s3-website-us-east-1.amazonaws.
com/vagrant_ubuntu_12.04.3_amd64_virtualbox.box' |
| 18 else |
| 19 config.vm.box = 'precise64' |
| 20 config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/curren
t/precise-server-cloudimg-amd64-vagrant-disk1.box' |
| 21 end |
| 17 config.vm.host_name = "#{host_name}.adblockplus.org" | 22 config.vm.host_name = "#{host_name}.adblockplus.org" |
| 18 config.vm.network :private_network, ip: ip | 23 config.vm.network :private_network, ip: ip |
| 19 config.vm.provider :virtualbox do |vb| | 24 config.vm.provider :virtualbox do |vb| |
| 20 vb.customize ["modifyvm", :id, "--cpus", 1] | 25 vb.customize ["modifyvm", :id, "--cpus", 1] |
| 21 | 26 |
| 22 # Work around https://www.virtualbox.org/ticket/11649 | 27 # Work around https://www.virtualbox.org/ticket/11649 |
| 23 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] | 28 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] |
| 24 | 29 |
| 25 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml") | 30 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml") |
| 26 setup = YAML.load_file(setup_path) rescue {} | 31 setup = YAML.load_file(setup_path) rescue {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | 64 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
| 60 config_path = File.join(REPOSITORY_DIR, "modules/private/hiera/hosts.yaml") | 65 config_path = File.join(REPOSITORY_DIR, "modules/private/hiera/hosts.yaml") |
| 61 config_data = YAML.load_file(config_path) | 66 config_data = YAML.load_file(config_path) |
| 62 servers = config_data["servers"] | 67 servers = config_data["servers"] |
| 63 servers.each do |server, items| | 68 servers.each do |server, items| |
| 64 ip = items["ip"][0] | 69 ip = items["ip"][0] |
| 65 role = items.fetch("role", "default") | 70 role = items.fetch("role", "default") |
| 66 define_standard_vm(config, server, ip, role) | 71 define_standard_vm(config, server, ip, role) |
| 67 end | 72 end |
| 68 end | 73 end |
| OLD | NEW |