Skip to content

Commit

Permalink
feat(local-vagrant): add more configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwalther committed May 23, 2017
1 parent 9dd6ecf commit 7122463
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 14 additions & 5 deletions local-vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ NUM_OF_MANAGERS=settings['NUM_OF_MANAGERS']
NUM_OF_WORKERS=settings['NUM_OF_WORKERS']
MEMORY=settings['MEMORY']
NUM_CPUS=settings['NUM_CPUS']
DEPLOY_STACK=settings['DEPLOY_STACK']
UPDATE_MACHINES=settings['UPDATE_MACHINES']

# -- Install the required plugins
require File.dirname(__FILE__)+"/lib/dependency_manager"
Expand Down Expand Up @@ -105,10 +107,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
node.vm.network "private_network", ip: "192.168.50.#{99+mgrNumber}"
node.vm.provider "virtualbox" do |v|
v.memory = MEMORY
v.cpus = 2
v.cpus = NUM_CPUS
v.name = "manager-#{mgrNumber}"
end
node.vm.provision "shell", inline: "sudo apt-get update"

if (UPDATE_MACHINES)
node.vm.provision "shell", inline: "sudo apt-get update"
end #if
node.vm.provision "docker"
node.vm.provision "shell", inline: @initManager, args: [ "#{NUM_OF_MANAGERS}" , "192.168.50.#{99+mgrNumber}", "#{mgrNumber}" ]
end
Expand All @@ -120,10 +125,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
node.vm.network "private_network", ip: "192.168.50.#{149+workerNumber}"
node.vm.provider "virtualbox" do |v|
v.memory = MEMORY
v.cpus = 2
v.cpus = NUM_CPUS
v.name = "worker-#{workerNumber}"
end
node.vm.provision "shell", inline: "sudo apt-get update"

if (UPDATE_MACHINES)
node.vm.provision "shell", inline: "sudo apt-get update"
end #if

node.vm.provision "docker"
node.vm.provision "shell", inline: @initWorker

Expand All @@ -134,7 +143,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# might be the better and more stable approach.

# Any hint welcome how to improve this ...
if NUM_OF_WORKERS == workerNumber
if (NUM_OF_WORKERS == workerNumber) && (DEPLOY_STACK)
node.vm.provision :host_shell do |host_shell|
host_shell.inline = 'mkdir .tmp';
host_shell.inline = 'cp ./../lib/docker-stack.yml .tmp';
Expand Down
4 changes: 4 additions & 0 deletions local-vagrant/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ NUM_OF_MANAGERS: 3
NUM_OF_WORKERS: 2
MEMORY: 1024
NUM_CPUS: 2

# Update the machines (sudo apt-get), takes more time
UPDATE_MACHINES: true
DEPLOY_STACK: true

0 comments on commit 7122463

Please sign in to comment.