From 73f8c9e9ae02891d9bbfeac8c90325efae6a6e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Schr=C3=B6der?= Date: Sat, 2 Apr 2016 23:13:29 +0200 Subject: [PATCH] Adds generic Vagrantfile and vagrant.yml with five nodes --- prepare-local/Vagrantfile | 78 +++++++++++++++++++++++++++++++++++++++ prepare-local/vagrant.yml | 41 ++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 prepare-local/Vagrantfile create mode 100644 prepare-local/vagrant.yml diff --git a/prepare-local/Vagrantfile b/prepare-local/Vagrantfile new file mode 100644 index 00000000..af535089 --- /dev/null +++ b/prepare-local/Vagrantfile @@ -0,0 +1,78 @@ +# vim: set filetype=ruby: +require 'yaml' +require 'vagrant-vbguest' unless defined? VagrantVbguest::Config + +configuration_file = File.expand_path("vagrant.yml", File.dirname(__FILE__)) +configuration = YAML.load_file configuration_file +settings = configuration['vagrant'] +instances = configuration['instances'] + +$enable_serial_logging = false + +Vagrant.configure('2') do |config| + + def check_dependency(plugin_name) + unless Vagrant.has_plugin?(plugin_name) + puts "Vagrant [" + plugin_name + "] is required but is not installed\n" + + "please check if you have the plugin with the following command:\n" + + " $ vagrand plugin list\n" + + "If needed install the plugin:\n" + + " $ vagrant plugin install " + plugin_name + "\n" + abort "Missing [" + plugin_name + "] plugin\n\n" + end + end + + check_dependency 'vagrant-vbguest' + + config.vm.box = settings['default_box'] + config.vm.box_url = settings['default_box_url'] + config.ssh.forward_agent = true + config.ssh.insert_key = settings['ssh_insert_key'] + config.vm.box_check_update = true + config.vbguest.auto_update = false + + instances.each do |instance| + + next if instance.has_key? 'deactivated' and instance['deactivated'] + + config.vm.define instance['hostname'] do |guest| + + if instance.has_key? 'box' + guest.vm.box = instance['box'] + end + if instance.has_key? 'box_url' + guest.vm.box_url = instance['box_url'] + end + + if instance.has_key? 'private_ip' + guest.vm.network 'private_network', ip: instance['private_ip'] + end + + guest.vm.provider 'virtualbox' do |vb| + if instance.has_key? 'cpu_execution_cap' + vb.customize ["modifyvm", :id, "--cpuexecutioncap", instance['cpu_execution_cap'].to_s] + end + + vb.customize ["modifyvm", :id, "--nictype1", "virtio"] + vb.customize ["modifyvm", :id, "--nictype2", "virtio"] + + if instance.has_key? 'memory' + vb.memory = instance['memory'] + end + + if instance.has_key? 'cores' + vb.cpus = instance['cores'] + end + end + + if instance.has_key? 'mounts' + instance['mounts'].each do |mount| + guest.vm.synced_folder mount['host_path'], mount['guest_path'], owner: mount['owner'], group: mount['group'] + end + end + + end + + end + +end diff --git a/prepare-local/vagrant.yml b/prepare-local/vagrant.yml new file mode 100644 index 00000000..544aead7 --- /dev/null +++ b/prepare-local/vagrant.yml @@ -0,0 +1,41 @@ +--- +vagrant: + + default_box: debian-7.2.0 + default_box_url: https://dl.dropboxusercontent.com/u/197673519/debian-7.2.0.box + default_box_check_update: true + ssh_insert_key: false + min_memory: 256 + min_cores: 1 + +instances: + + - hostname: node1 + private_ip: 10.10.10.10 + memory: 512 + cores: 1 + mounts: + - host_path: ../ + guest_path: /home/vagrant/orchestration-workshop + owner: vagrant + group: vagrant + + - hostname: node2 + private_ip: 10.10.10.20 + memory: 512 + cores: 1 + + - hostname: node3 + private_ip: 10.10.10.30 + memory: 512 + cores: 1 + + - hostname: node4 + private_ip: 10.10.10.40 + memory: 512 + cores: 1 + + - hostname: node5 + private_ip: 10.10.10.50 + memory: 512 + cores: 1