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

Delta Between Two Patch Sets: Vagrantfile

Issue 4810150141493248: Issue 122 - Puppet ENC via Hiera (Closed)
Left Patch Set: 112 - Integrate run.py and monitoring with Hiera Created Feb. 26, 2015, 5:32 p.m.
Right Patch Set: Puppet ENC via Hiera - Without Arrow Alignment Created March 16, 2015, 2:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « README.md ('k') | hiera/hiera.yaml » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
16 config.vm.box = 'precise64' 15 config.vm.box = 'precise64'
17 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'
18 config.vm.host_name = "#{host_name}.adblockplus.org" 17 config.vm.host_name = "#{host_name}.adblockplus.org"
19 config.vm.network :private_network, ip: ip 18 config.vm.network :private_network, ip: ip
20 config.vm.provider :virtualbox do |vb| 19 config.vm.provider :virtualbox do |vb|
21
22 vb.customize ["modifyvm", :id, "--cpus", 1] 20 vb.customize ["modifyvm", :id, "--cpus", 1]
23 21
24 # Work around https://www.virtualbox.org/ticket/11649 22 # Work around https://www.virtualbox.org/ticket/11649
25 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on'] 23 vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
26 24
27 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml") 25 setup_path = File.join(REPOSITORY_DIR, "hiera", "roles", "#{role}.yaml")
28 setup = YAML.load_file(setup_path) rescue {} 26 setup = YAML.load_file(setup_path) rescue {}
29 requirements = setup.fetch("requirements", {}) 27 requirements = setup.fetch("requirements", {})
30 28
31 requirements.each do |key, value| 29 requirements.each do |key, value|
32 vb.customize ['modifyvm', :id, "--#{key}", "#{value}"] 30 vb.customize ['modifyvm', :id, "--#{key}", "#{value}"]
33 end 31 end
34 32
35 end 33 end
36 34
37 # The repository location in the production system's puppet master 35 # The repository location in the production system's puppet master
38 config.vm.synced_folder ".", "/etc/puppet/infrastructure" 36 config.vm.synced_folder ".", "/etc/puppet/infrastructure"
39 37
40 config.vm.provision :shell, :inline => ' 38 config.vm.provision :shell, :inline => '
41 sudo /etc/puppet/infrastructure/hiera/install-precise.py 39 sudo /etc/puppet/infrastructure/hiera/install_precise.py
42 ' 40 '
43 41
44 config.vm.provision :puppet do |puppet| 42 config.vm.provision :puppet do |puppet|
45 puppet.options = [ 43 puppet.options = [
46 '--environment=development', 44 '--environment=development',
47 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet-node-classifie r.rb', 45 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet_node_classifie r.rb',
48 '--node_terminus=exec', 46 '--node_terminus=exec',
49 '--verbose', 47 '--verbose',
50 '--debug', 48 '--debug',
51 ] 49 ]
52 puppet.manifests_path = 'manifests' 50 puppet.manifests_path = 'manifests'
53 puppet.manifest_file = 'nodes.pp' 51 puppet.manifest_file = 'nodes.pp'
54 puppet.module_path = 'modules' 52 puppet.module_path = 'modules'
55 # Requires Puppet 3.x or later
56 #puppet.hiera_config_path = 'hiera/vagrant.yaml'
57 end 53 end
58 54
59 yield(config) if block_given? 55 yield(config) if block_given?
60
61 end 56 end
62 end 57 end
63 58
64 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 59 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
65 configYAML = File.join(REPOSITORY_DIR, "hiera/private/hosts.yaml") 60 config_path = File.join(REPOSITORY_DIR, "hiera/private/hosts.yaml")
66 configServers = YAML.load_file(configYAML) 61 config_data = YAML.load_file(config_path)
67 servers = configServers["servers"] 62 servers = config_data["servers"]
68 servers.each do |server, items| 63 servers.each do |server, items|
69 ip = items["ip"][0] 64 ip = items["ip"][0]
70 role = items.fetch("role", "default") 65 role = items.fetch("role", "default")
71 define_standard_vm(config, server, ip, role) 66 define_standard_vm(config, server, ip, role)
72 end 67 end
73 end 68 end
LEFTRIGHT

Powered by Google App Engine
This is Rietveld