Left: | ||
Right: |
OLD | NEW |
---|---|
1 require 'yaml' | |
2 | |
1 VAGRANTFILE_API_VERSION = "2" | 3 VAGRANTFILE_API_VERSION = "2" |
2 REPOSITORY_DIR = File.dirname(__FILE__) | 4 REPOSITORY_DIR = File.dirname(__FILE__) |
3 DEPENDENCY_SCRIPT = File.join(REPOSITORY_DIR, "ensure_dependencies.py") | 5 DEPENDENCY_SCRIPT = File.join(REPOSITORY_DIR, "ensure_dependencies.py") |
4 | 6 |
5 if !system("python", DEPENDENCY_SCRIPT) | 7 if !system("python", DEPENDENCY_SCRIPT) |
6 error = Vagrant::Errors::VagrantError | 8 error = Vagrant::Errors::VagrantError |
7 error.error_message("Failed to ensure dependencies being up-to-date!") | 9 error.error_message("Failed to ensure dependencies being up-to-date!") |
8 raise error | 10 raise error |
9 end | 11 end |
10 | 12 |
11 def define_standard_vm(config, host_name, ip) | 13 def define_standard_vm(config, host_name, ip, role=nil) |
12 config.vm.define host_name do |config| | 14 config.vm.define host_name do |config| |
15 | |
13 config.vm.box = 'precise64' | 16 config.vm.box = 'precise64' |
14 config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/current/ precise-server-cloudimg-amd64-vagrant-disk1.box' | 17 config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/current/ precise-server-cloudimg-amd64-vagrant-disk1.box' |
15 config.vm.host_name = "#{host_name}.adblockplus.org" | 18 config.vm.host_name = "#{host_name}.adblockplus.org" |
16 config.vm.network :private_network, ip: ip | 19 config.vm.network :private_network, ip: ip |
17 config.vm.provider :virtualbox do |vb| | 20 config.vm.provider :virtualbox do |vb| |
21 | |
18 vb.customize ["modifyvm", :id, "--cpus", 1] | 22 vb.customize ["modifyvm", :id, "--cpus", 1] |
19 | 23 |
20 # Work around https://www.virtualbox.org/ticket/11649 | 24 # Work around https://www.virtualbox.org/ticket/11649 |
21 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] | 25 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] |
26 | |
27 if role == nil | |
Wladimir Palant
2014/11/17 16:43:36
Can role ever be nil? I don't think we want to hav
mathias
2014/11/27 00:30:18
Agreed, we do not need a host being configured by
| |
28 setup_path = File.join(Dir.pwd, "hiera", "hosts", "#{host_name}.yaml") | |
Wladimir Palant
2014/11/17 16:43:36
Please don't use Dir.pwd here or elsewhere, its va
mathias
2014/11/27 00:30:18
Done.
| |
29 else | |
30 setup_path = File.join(Dir.pwd, "hiera", "roles", "#{role}.yaml") | |
31 end | |
32 | |
33 setup = YAML.load_file(setup_path) rescue {} | |
34 requirements = setup.fetch("requirements", {}) | |
35 | |
36 requirements.each do |key, value| | |
37 vb.customize ['modifyvm', :id, "--#{key}", "#{value}"] | |
38 end | |
39 | |
22 end | 40 end |
23 | 41 |
42 # The repository location in the production system's puppet master | |
43 config.vm.synced_folder ".", "/etc/puppet/infrastructure" | |
44 | |
24 config.vm.provision :shell, :inline => ' | 45 config.vm.provision :shell, :inline => ' |
25 if ! test -f /usr/bin/puppet; then | 46 sudo /etc/puppet/infrastructure/hiera/install-precise.py |
26 sudo apt-get update && sudo apt-get install -y puppet | 47 ' |
27 fi' | |
28 | 48 |
29 manifest_files = ['vagrant.pp', 'nodes.pp'] | 49 config.vm.provision :puppet do |puppet| |
30 manifest_files.each do |manifest_file| | 50 puppet.options = [ |
31 config.vm.provision :puppet do |puppet| | 51 '--environment=development', |
32 puppet.options = ['--environment=development'] | 52 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet-node-classifie r.rb', |
33 puppet.manifests_path = 'manifests' | 53 '--node_terminus=exec', |
34 puppet.manifest_file = manifest_file | 54 '--verbose', |
35 puppet.module_path = 'modules' | 55 '--debug', |
Wladimir Palant
2014/11/17 16:43:36
Debug output isn't going to be too useful, right?
mathias
2014/11/27 00:30:18
It is super useful! It doesn't seem to make much s
| |
36 end | 56 ] |
57 puppet.manifests_path = 'manifests' | |
58 puppet.manifest_file = 'nodes.pp' | |
59 puppet.module_path = 'modules' | |
60 # Requires Puppet 3.x or later | |
61 #puppet.hiera_config_path = 'hiera/vagrant.yaml' | |
37 end | 62 end |
38 | 63 |
39 yield(config) if block_given? | 64 yield(config) if block_given? |
65 | |
40 end | 66 end |
41 end | 67 end |
42 | 68 |
43 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | 69 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
44 define_standard_vm config, 'server4', '10.8.0.99' | 70 configYAML = File.join(Dir.pwd, "hiera/environment/hosts.yaml") |
45 define_standard_vm config, 'server5', '10.8.0.100' | 71 configServers = YAML.load_file(configYAML) |
46 define_standard_vm config, 'server6', '10.8.0.101' | 72 servers = configServers["servers"] |
47 define_standard_vm config, 'server7', '10.8.0.102' | 73 servers.each do |server, items| |
48 define_standard_vm config, 'server10', '10.8.0.105' do |config| | 74 ip = items["ip"][0] |
49 config.vm.provider :virtualbox do |vb| | 75 role = items.fetch("role", "default") |
50 vb.customize ["modifyvm", :id, "--memory", 1024] | 76 define_standard_vm(config, server, ip, role) |
51 end | |
52 end | 77 end |
53 define_standard_vm config, 'server11', '10.8.0.106' | |
54 define_standard_vm config, 'server12', '10.8.0.107' | |
55 define_standard_vm config, 'server15', '10.8.0.110' | |
56 define_standard_vm config, 'server19', '10.8.0.114' | |
57 define_standard_vm config, 'notification1', '10.8.0.118' | |
58 define_standard_vm config, 'notification2', '10.8.0.119' | |
59 define_standard_vm config, 'filter1', '10.8.0.120' | |
60 define_standard_vm config, 'filter2', '10.8.0.121' | |
61 define_standard_vm config, 'filter3', '10.8.0.122' | |
62 define_standard_vm config, 'filter4', '10.8.0.123' | |
63 define_standard_vm config, 'filter5', '10.8.0.124' | |
64 define_standard_vm config, 'filter6', '10.8.0.125' | |
65 define_standard_vm config, 'download1', '10.8.0.126' | |
66 define_standard_vm config, 'filtermaster1', '10.8.0.127' | |
67 define_standard_vm config, 'update1', '10.8.0.128' | |
68 define_standard_vm config, 'web1', '10.8.0.129' | |
69 define_standard_vm config, 'stats1', '10.8.0.130' | |
70 define_standard_vm config, 'issues1', '10.8.0.131' | |
71 define_standard_vm config, 'codereview1', '10.8.0.132' | |
72 define_standard_vm config, 'filter7', '10.8.0.133' | |
73 define_standard_vm config, 'filter8', '10.8.0.134' | |
74 define_standard_vm config, 'filter9', '10.8.0.135' | |
75 define_standard_vm config, 'filter10', '10.8.0.136' | |
76 define_standard_vm config, 'filter11', '10.8.0.137' | |
77 define_standard_vm config, 'filter12', '10.8.0.138' | |
78 define_standard_vm config, 'filter13', '10.8.0.139' | |
79 define_standard_vm config, 'filter14', '10.8.0.140' | |
80 define_standard_vm config, 'filter15', '10.8.0.141' | |
81 define_standard_vm config, 'filter16', '10.8.0.142' | |
82 define_standard_vm config, 'filter17', '10.8.0.143' | |
83 define_standard_vm config, 'filter18', '10.8.0.144' | |
84 end | 78 end |
OLD | NEW |