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: Puppet ENC via Hiera Created March 16, 2015, 12:06 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|
13 config.vm.box = 'precise64' 15 config.vm.box = 'precise64'
14 config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/current/ precise-server-cloudimg-amd64-vagrant-disk1.box' 16 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" 17 config.vm.host_name = "#{host_name}.adblockplus.org"
16 config.vm.network :private_network, ip: ip 18 config.vm.network :private_network, ip: ip
17 config.vm.provider :virtualbox do |vb| 19 config.vm.provider :virtualbox do |vb|
18 vb.customize ["modifyvm", :id, "--cpus", 1] 20 vb.customize ["modifyvm", :id, "--cpus", 1]
19 21
20 # Work around https://www.virtualbox.org/ticket/11649 22 # Work around https://www.virtualbox.org/ticket/11649
21 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] 23 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
24
25 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml")
26 setup = YAML.load_file(setup_path) rescue {}
27 requirements = setup.fetch("requirements", {})
28
29 requirements.each do |key, value|
30 vb.customize ['modifyvm', :id, "--#{key}", "#{value}"]
31 end
32
22 end 33 end
23 34
35 # The repository location in the production system's puppet master
36 config.vm.synced_folder ".", "/etc/puppet/infrastructure"
37
24 config.vm.provision :shell, :inline => ' 38 config.vm.provision :shell, :inline => '
25 if ! test -f /usr/bin/puppet; then 39 sudo /etc/puppet/infrastructure/hiera/install_precise.py
26 sudo apt-get update && sudo apt-get install -y puppet 40 '
27 fi'
28 41
29 manifest_files = ['vagrant.pp', 'nodes.pp'] 42 config.vm.provision :puppet do |puppet|
30 manifest_files.each do |manifest_file| 43 puppet.options = [
31 config.vm.provision :puppet do |puppet| 44 '--environment=development',
32 puppet.options = ['--environment=development'] 45 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet_node_classifie r.rb',
33 puppet.manifests_path = 'manifests' 46 '--node_terminus=exec',
34 puppet.manifest_file = manifest_file 47 '--verbose',
35 puppet.module_path = 'modules' 48 '--debug',
36 end 49 ]
50 puppet.manifests_path = 'manifests'
51 puppet.manifest_file = 'nodes.pp'
52 puppet.module_path = 'modules'
37 end 53 end
38 54
39 yield(config) if block_given? 55 yield(config) if block_given?
40 end 56 end
41 end 57 end
42 58
43 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 59 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
44 define_standard_vm config, 'server4', '10.8.0.99' 60 config_path = File.join(REPOSITORY_DIR, "hiera/private/hosts.yaml")
45 define_standard_vm config, 'server5', '10.8.0.100' 61 config_data = YAML.load_file(config_path)
46 define_standard_vm config, 'server6', '10.8.0.101' 62 servers = config_data["servers"]
47 define_standard_vm config, 'server7', '10.8.0.102' 63 servers.each do |server, items|
48 define_standard_vm config, 'server10', '10.8.0.105' do |config| 64 ip = items["ip"][0]
49 config.vm.provider :virtualbox do |vb| 65 role = items.fetch("role", "default")
50 vb.customize ["modifyvm", :id, "--memory", 1024] 66 define_standard_vm(config, server, ip, role)
51 end
52 end 67 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 define_standard_vm config, 'web2', '10.8.0.145'
85 end 68 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