From d56b179f018ede409973e3c0cd9cd2364ebf261f Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Wed, 2 Sep 2015 09:56:21 +0200 Subject: [PATCH] Added possibility to ajdust Vagrantfile settings from yml file --- Vagrantfile | 25 +++++++++++++++---------- vagrant-settings.yml_defaults | 6 ++++++ 2 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 vagrant-settings.yml_defaults diff --git a/Vagrantfile b/Vagrantfile index 387609ba..a1880545 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,9 +1,19 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +require 'yaml' + # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 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=[]) "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| v.customize [ "modifyvm", :id, - "--memory", 1024, + "--memory", MASTER_RAM, "--paravirtprovider", "kvm" # for linux guest ] v.name = "solar-dev" @@ -46,13 +56,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| index = i + 1 ip_index = i + 3 config.vm.define "solar-dev#{index}" do |config| - # Box solar-dev3 is for 'solar_bootstrap' resource demo - if index == 3 then - config.vm.box = "ubuntu/trusty64" - else - # standard box with all stuff preinstalled - config.vm.box = "cgenie/solar-master" - end + # standard box with all stuff preinstalled + config.vm.box = "cgenie/solar-master" config.vm.provision "shell", inline: slave_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| v.customize [ "modifyvm", :id, - "--memory", 1024, + "--memory", SLAVES_RAM, "--paravirtprovider", "kvm" # for linux guest ] v.name = "solar-dev#{index}" diff --git a/vagrant-settings.yml_defaults b/vagrant-settings.yml_defaults new file mode 100644 index 00000000..b727c0b7 --- /dev/null +++ b/vagrant-settings.yml_defaults @@ -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