Added possibility to ajdust Vagrantfile settings from yml file

This commit is contained in:
Jedrzej Nowak 2015-09-02 09:56:21 +02:00
parent accc44f10d
commit d56b179f01
2 changed files with 21 additions and 10 deletions

25
Vagrantfile vendored
View File

@ -1,9 +1,19 @@
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2" VAGRANTFILE_API_VERSION = "2"
SLAVES_COUNT = 2 if File.exist?('vagrant-settings.yml')
cfg = YAML.load_file('vagrant-settings.yml')
else
cfg = {}
end
SLAVES_COUNT = cfg.fetch("slaves_count", 2)
SLAVES_RAM = cfg.fetch("slaves_ram", 1024)
MASTER_RAM = cfg.fetch("master_ram", 1024)
def ansible_playbook_command(filename, args=[]) def ansible_playbook_command(filename, args=[])
"ansible-playbook -v -i \"localhost,\" -c local /vagrant/bootstrap/playbooks/#{filename} #{args.join ' '}" "ansible-playbook -v -i \"localhost,\" -c local /vagrant/bootstrap/playbooks/#{filename} #{args.join ' '}"
@ -35,7 +45,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :virtualbox do |v| config.vm.provider :virtualbox do |v|
v.customize [ v.customize [
"modifyvm", :id, "modifyvm", :id,
"--memory", 1024, "--memory", MASTER_RAM,
"--paravirtprovider", "kvm" # for linux guest "--paravirtprovider", "kvm" # for linux guest
] ]
v.name = "solar-dev" v.name = "solar-dev"
@ -46,13 +56,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
index = i + 1 index = i + 1
ip_index = i + 3 ip_index = i + 3
config.vm.define "solar-dev#{index}" do |config| config.vm.define "solar-dev#{index}" do |config|
# Box solar-dev3 is for 'solar_bootstrap' resource demo # standard box with all stuff preinstalled
if index == 3 then config.vm.box = "cgenie/solar-master"
config.vm.box = "ubuntu/trusty64"
else
# standard box with all stuff preinstalled
config.vm.box = "cgenie/solar-master"
end
config.vm.provision "shell", inline: slave_script, privileged: true config.vm.provision "shell", inline: slave_script, privileged: true
config.vm.provision "shell", inline: solar_script, privileged: true config.vm.provision "shell", inline: solar_script, privileged: true
@ -63,7 +68,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :virtualbox do |v| config.vm.provider :virtualbox do |v|
v.customize [ v.customize [
"modifyvm", :id, "modifyvm", :id,
"--memory", 1024, "--memory", SLAVES_RAM,
"--paravirtprovider", "kvm" # for linux guest "--paravirtprovider", "kvm" # for linux guest
] ]
v.name = "solar-dev#{index}" v.name = "solar-dev#{index}"

View File

@ -0,0 +1,6 @@
# rename it to vagrant-settings.yml then Vagrantfile
# will use values from this file
slaves_count: 2
slaves_ram: 1024
master_ram: 1024