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: Created Sept. 8, 2014, 11:56 a.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 VAGRANTFILE_API_VERSION = "2"
2 require 'yaml' 1 require 'yaml'
3 2
4 def define_standard_vm(config, host_name, ip) 3 VAGRANTFILE_API_VERSION = "2"
4 REPOSITORY_DIR = File.dirname(__FILE__)
5 DEPENDENCY_SCRIPT = File.join(REPOSITORY_DIR, "ensure_dependencies.py")
6
7 if !system("python", DEPENDENCY_SCRIPT)
8 error = Vagrant::Errors::VagrantError
9 error.error_message("Failed to ensure dependencies being up-to-date!")
10 raise error
11 end
12
13 def define_standard_vm(config, host_name, ip, role=nil)
5 config.vm.define host_name do |config| 14 config.vm.define host_name do |config|
6
7 config.vm.box = 'precise64' 15 config.vm.box = 'precise64'
8 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'
9 config.vm.host_name = "#{host_name}.adblockplus.org" 17 config.vm.host_name = "#{host_name}.adblockplus.org"
10 config.vm.network :private_network, ip: ip 18 config.vm.network :private_network, ip: ip
11 config.vm.provider :virtualbox do |vb| 19 config.vm.provider :virtualbox do |vb|
12 vb.customize ["modifyvm", :id, "--cpus", 1] 20 vb.customize ["modifyvm", :id, "--cpus", 1]
21
13 # Work around https://www.virtualbox.org/ticket/11649 22 # Work around https://www.virtualbox.org/ticket/11649
14 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
15 end 33 end
16 34
17 config.vm.provision :shell, :path => 'hiera/files/precise.sh' 35 # The repository location in the production system's puppet master
36 config.vm.synced_folder ".", "/etc/puppet/infrastructure"
37
38 config.vm.provision :shell, :inline => '
39 sudo /etc/puppet/infrastructure/hiera/install_precise.py
40 '
41
18 config.vm.provision :puppet do |puppet| 42 config.vm.provision :puppet do |puppet|
19 puppet.options = [ 43 puppet.options = [
20 '--environment=development', 44 '--environment=development',
21 '--external_nodes=/usr/local/bin/puppet-node-classifier', 45 '--external_nodes=/etc/puppet/infrastructure/hiera/puppet_node_classifie r.rb',
22 '--node_terminus=exec', 46 '--node_terminus=exec',
47 '--verbose',
48 '--debug',
23 ] 49 ]
24 puppet.manifests_path = 'manifests' 50 puppet.manifests_path = 'manifests'
25 puppet.manifest_file = 'nodes.pp' 51 puppet.manifest_file = 'nodes.pp'
26 puppet.module_path = 'modules' 52 puppet.module_path = 'modules'
27 # Requires Puppet 3.x or later
28 #puppet.hiera_config_path = 'hiera/vagrant.yaml'
29 end 53 end
30 54
31 yield(config) if block_given? 55 yield(config) if block_given?
32
33 end 56 end
34 end 57 end
35 58
36
37 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 59 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
38 configYAML = File.join(Dir.pwd, "hiera/environments/development/hosts.yaml") 60 config_path = File.join(REPOSITORY_DIR, "hiera/private/hosts.yaml")
39 configServers = YAML.load_file(configYAML) 61 config_data = YAML.load_file(config_path)
40 servers = configServers["servers"] 62 servers = config_data["servers"]
41 servers.each do |server, items| 63 servers.each do |server, items|
42 define_standard_vm(config, server, items["ip"][0]) 64 ip = items["ip"][0]
65 role = items.fetch("role", "default")
66 define_standard_vm(config, server, ip, role)
43 end 67 end
44 end 68 end
LEFTRIGHT

Powered by Google App Engine
This is Rietveld