Vagrantfile retrieve vagrant parameter call

9 views
Skip to first unread message

Eric Keller

unread,
Oct 18, 2016, 10:26:49 AM10/18/16
to Vagrant
Hi everyone,

Vagrant version
Vagrant 1.8.4

Host operating system

NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.1 LTS"
VERSION_ID="16.04"
UBUNTU_CODENAME=xenial

Guest operating system

jessie libvirt

Vagrantfile

# automatically restart dnsmasq in the right order
# this is a hack until libvirt do not mess-up with dnsmasq.service!
system('./restart_dns.sh --force')
...
normal multi-box vagrantfile
...
I would like to reset the dns only when calling vagrant up therefore I would like to know if I can detect the parameter with wich vagrant is called?

for example:

vagrant up => in the Vagrantfile I would like to get the "up" as a variable I can put some condition on.

Best Regards

--
Eric


Torben Knerr

unread,
Oct 18, 2016, 1:42:21 PM10/18/16
to vagra...@googlegroups.com
Hi Eric,

if you don't mind installing an extra plugin, then vagrant-triggers might be your friend:

If it's only for that simple case (i.e. detecting "up", but no other state transitition depedencies), then parsing the commandline args via ARGV[0] might be good enough:

Cheers,
Torben 

--
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 vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/38be2b91-566a-4f2b-9d58-a06f8fc1440b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Keller

unread,
Oct 19, 2016, 2:34:13 AM10/19/16
to Vagrant
Hi Torben,

thank you so much, the Stackoverflow link did the trick, it's so easy when you know the solution :)

have a nice day
--
Eric
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages