Accessing the current command from Vagrantfile

59 views
Skip to first unread message

Oliver Dungey

unread,
May 10, 2016, 4:39:42 AM5/10/16
to Vagrant
I have a complex Vagrantfile with many servers and custom functionality in it. Within my Vagrantfile I would like to perform certain operations based on the current Vagrant command (up/status/destroy etc.) - is there a way I can get hold of information about the current command within the Vagrantfile? I've tried to work it out from the source code but my Ruby is very limited, any assistance would be much appreciated.

Alvaro Miranda Aguilera

unread,
May 10, 2016, 5:24:12 PM5/10/16
to vagra...@googlegroups.com
Hello,

You can use:

ARGV[0] == up

ie:

<do_this> if ARGV[0] == up

or:


if ARGV[0] == up
  <do_this>
  <and_this>
end


Alvaro.




On Tue, May 10, 2016 at 8:39 PM, Oliver Dungey <oliver...@gmail.com> wrote:
I have a complex Vagrantfile with many servers and custom functionality in it. Within my Vagrantfile I would like to perform certain operations based on the current Vagrant command (up/status/destroy etc.) - is there a way I can get hold of information about the current command within the Vagrantfile? I've tried to work it out from the source code but my Ruby is very limited, any assistance would be much appreciated.

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/6f20414f-6279-4454-966f-9a12ce53c985%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oliver Dungey

unread,
May 11, 2016, 10:39:23 AM5/11/16
to Vagrant
Thanks Alvaro, exactly what I needed.
Reply all
Reply to author
Forward
0 new messages