The if *after* the post_up_message??
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
#------
# Spin up three VM's, set hostnames and assign IP's.
#------
(1..3).each do |i|
config.vm.define "node#{i}" do |node|
node.vm.box = "ubuntu/xenial64"
node.vm.hostname = "node#{i}"
node.vm.network "private_network", ip: "192.168.50.1#{i}"
#-----
# Each VM needs to have two block devices. 1GB local storage each
# for the purpose of this exercise, and attached to the VM's.
#-----
node.vm.provider "virtualbox" do |vb|
#-----
# If disks don't already exist, create them.
#-----
unless FileTest.exist?("node#{i}_disk1.vdi")
vb.customize ['createhd', '--filename', "node#{i}_disk1.vdi",
'--variant', 'Fixed', '--size', 1 * 1024]
end
unless FileTest.exist?("node#{i}_disk2.vdi")
vb.customize ['createhd', '--filename', "node#{i}_disk2.vdi",
'--variant', 'Fixed', '--size', 1 * 1024]
end
#-----
# Attach the drives to the SCSI controller.
#-----
# !! NOTE: This step is specific to the ubuntu/xenial64 box.
# !! If you change the box, these next two commands will likely fail!
# !! (Extra credit if you can figure out *why* they will likely fail.)
#-----
vb.customize ['storageattach', :id, '--storagectl', 'SCSI',
'--port', 2, '--device', 0, '--type', 'hdd', '--medium',
"node#{i}_disk1.vdi"]
vb.customize ['storageattach', :id, '--storagectl', 'SCSI',
'--port', 3, '--device', 0, '--type', 'hdd', '--medium',
"node#{i}_disk2.vdi"]
end
#-----
# Do all the common configuration work
#-----
node.vm.provision "shell", path: "./provision/common.sh"
#-----
# Configure and setup the Consul and Nomad clusters
#-----
case i
when 1
node.vm.provision "shell", path: "./provision/consulserver.sh"
node.vm.provision "shell", path: "./provision/nomadserver.sh"
when 2
node.vm.provision "shell", path: "./provision/consulagent1.sh"
node.vm.provision "shell", path: "./provision/nomadclient1.sh"
when 3
node.vm.provision "shell", path: "./provision/consulagent2.sh"
node.vm.provision "shell", path: "./provision/nomadclient2.sh"
end
#----
# Configure and run cadvisor with Nomad
#----
node.vm.provision "shell", path: "./provision/cadvisor.sh"
end
end
end
On Mon, Oct 2, 2017 at 10:12 PM, Alvaro Miranda Aguilera <[email protected]>
wrote:
> you can *if* on the loop
>
> say you loop 0 to 2 on a var i
>
> web01.vm.post_up_message = "hello" if i==2
>
>
>
> please share the vagrantfile so I can test and share a working example
>
> Alvaro
>
> On Mon, Oct 2, 2017 at 12:29 PM, Juan Jiménez <[email protected]> wrote:
>
>> There is only one VM block and a loop to create the three VM's. They are
>> essentially identical, with small differences, so no point in copying
>> everything three times. That is why this solution does not work.
>>
>> On Mon, Oct 2, 2017 at 9:13 AM, Alvaro Miranda Aguilera <
>> [email protected]> wrote:
>>
>>> on the last VM block, say its "web01" you can put
>>>
>>> web01.vm.post_up_message
>>>
>>> On Sun, Oct 1, 2017 at 8:05 PM, Juan Jiménez <[email protected]> wrote:
>>>
>>>> I want to puts a message at the very end of all processing of my
>>>> Vagrantfile, but I can't use the config.vm.post_up_message because I
>>>> am creating three vm's in a dev cluster and I don't want the message shown
>>>> three times. Any ideas?
>>>>
>>>> --
>>>> This mailing list is governed under the HashiCorp Community Guidelines
>>>> - https://www.hashicorp.com/community-guidelines.html. Behavior in
>>>> violation of those guidelines may result in your removal from this mailing
>>>> list.
>>>>
>>>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>>>> IRC: #vagrant on Freenode
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Vagrant" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/vagrant-up/cc05b644-e8df-46ea-b5fa-c43a590d4f79%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/vagrant-up/cc05b644-e8df-46ea-b5fa-c43a590d4f79%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Alvaro
>>>
>>> --
>>> This mailing list is governed under the HashiCorp Community Guidelines -
>>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>>> violation of those guidelines may result in your removal from this mailing
>>> list.
>>>
>>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>>> IRC: #vagrant on Freenode
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Vagrant" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/vagrant-up/065bLYW4YpY/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/vagrant-up/CAHqq0eytrgEBqyuzYTi8%3DON0T9KT3roXtcL0zhC1bD
>>> wCk9HtpA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/vagrant-up/CAHqq0eytrgEBqyuzYTi8%3DON0T9KT3roXtcL0zhC1bDwCk9HtpA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> This mailing list is governed under the HashiCorp Community Guidelines -
>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>> violation of those guidelines may result in your removal from this mailing
>> list.
>>
>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>> IRC: #vagrant on Freenode
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Vagrant" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/vagrant-up/CANxHLxQTngcqV59ySREzsQoN-m3cidyq7MzkxE0UeBmB
>> vpVJug%40mail.gmail.com
>> <https://groups.google.com/d/msgid/vagrant-up/CANxHLxQTngcqV59ySREzsQoN-m3cidyq7MzkxE0UeBmBvpVJug%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Alvaro
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Vagrant" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/vagrant-up/065bLYW4YpY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/vagrant-up/CAHqq0ewJh9AJ9%2BhJ9510ebMMY_
> E%3DX2xg_zP7WEv%2BztQiQStPwg%40mail.gmail.com
> <https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewJh9AJ9%2BhJ9510ebMMY_E%3DX2xg_zP7WEv%2BztQiQStPwg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/CANxHLxRPvseeF8RnYqavAjAK9P5TXE-0t%2BJANr_FVrKwY4CXZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.