Added possibility to ajdust Vagrantfile settings from yml file
This commit is contained in:
parent
accc44f10d
commit
d56b179f01
21
Vagrantfile
vendored
21
Vagrantfile
vendored
@ -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
|
||||
|
||||
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}"
|
||||
|
6
vagrant-settings.yml_defaults
Normal file
6
vagrant-settings.yml_defaults
Normal 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
|
Loading…
Reference in New Issue
Block a user