Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: Vagrantfile

Issue 4810150141493248: Issue 122 - Puppet ENC via Hiera (Closed)
Patch Set: 112 - Integrate run.py and monitoring with Hiera Created Feb. 26, 2015, 5:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « README.md ('k') | hiera/hiera.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml")
28 setup = YAML.load_file(setup_path) rescue {}
29 requirements = setup.fetch("requirements", {})
30
31 requirements.each do |key, value|
32 vb.customize ['modifyvm', :id, "--#{key}", "#{value}"]
33 end
34
22 end 35 end
23 36
37 # The repository location in the production system's puppet master
38 config.vm.synced_folder ".", "/etc/puppet/infrastructure"
39
24 config.vm.provision :shell, :inline => ' 40 config.vm.provision :shell, :inline => '
25 if ! test -f /usr/bin/puppet; then 41 sudo /etc/puppet/infrastructure/hiera/install-precise.py
26 sudo apt-get update && sudo apt-get install -y puppet 42 '
27 fi'
28 43
29 manifest_files = ['vagrant.pp', 'nodes.pp'] 44 config.vm.provision :puppet do |puppet|
30 manifest_files.each do |manifest_file| 45 puppet.options = [
31 config.vm.provision :puppet do |puppet| 46 '--environment=development',
32 puppet.options = ['--environment=development'] 47 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet-node-classifie r.rb',
33 puppet.manifests_path = 'manifests' 48 '--node_terminus=exec',
34 puppet.manifest_file = manifest_file 49 '--verbose',
35 puppet.module_path = 'modules' 50 '--debug',
36 end 51 ]
52 puppet.manifests_path = 'manifests'
53 puppet.manifest_file = 'nodes.pp'
54 puppet.module_path = 'modules'
55 # Requires Puppet 3.x or later
56 #puppet.hiera_config_path = 'hiera/vagrant.yaml'
37 end 57 end
38 58
39 yield(config) if block_given? 59 yield(config) if block_given?
60
40 end 61 end
41 end 62 end
42 63
43 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 64 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
44 define_standard_vm config, 'server4', '10.8.0.99' 65 configYAML = File.join(REPOSITORY_DIR, "hiera/private/hosts.yaml")
45 define_standard_vm config, 'server5', '10.8.0.100' 66 configServers = YAML.load_file(configYAML)
46 define_standard_vm config, 'server6', '10.8.0.101' 67 servers = configServers["servers"]
47 define_standard_vm config, 'server7', '10.8.0.102' 68 servers.each do |server, items|
48 define_standard_vm config, 'server10', '10.8.0.105' do |config| 69 ip = items["ip"][0]
49 config.vm.provider :virtualbox do |vb| 70 role = items.fetch("role", "default")
50 vb.customize ["modifyvm", :id, "--memory", 1024] 71 define_standard_vm(config, server, ip, role)
51 end
52 end 72 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 73 end
OLDNEW
« no previous file with comments | « README.md ('k') | hiera/hiera.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld