Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow vagrant to execute scripts on host #4040

Closed
snowch opened this issue Jun 14, 2014 · 7 comments
Closed

Allow vagrant to execute scripts on host #4040

snowch opened this issue Jun 14, 2014 · 7 comments

Comments

@snowch
Copy link

snowch commented Jun 14, 2014

Some more complex vagrant environments require scripts to automate the workflow of vagrant for users. Usually, these scripts will be created with shell and batch files. An example bat file here and example shell script here

It would be great if I vagrant box providers could write scripts in ruby and use the vagrant's ruby environment to run the script. For example;

vagrant script setup_environment_with_desktop.rb

or

vagrant script setup_environment_without_desktop.rb

Using ruby will allow vagrant box providers to use the same script on all hosts operating systems.

The script would not be part of vagrant's life-cycle. It would purely be a mechanism for easily executing simple ruby scripts.

@snowch snowch changed the title Improvement: allow vagrant to execute ruby scripts on host Enhancement: allow vagrant to execute ruby scripts on host Jun 14, 2014
@andyjansson
Copy link

There's already been talks on integrating vagrant-triggers into core #3849

Should cover your needs.

@snowch
Copy link
Author

snowch commented Jun 17, 2014

Are triggers detached from the vagrant lifecycle (up, down, status, ..)?

When you run a standalone script, you sometimes want to manage the vagrant lifecycle from that script. With triggers it seems as though a script would only get executed as part of a lifecyle event?

@andyjansson
Copy link

@snowch Triggers react to lifecycle events, yes.

@snowch
Copy link
Author

snowch commented Jun 17, 2014

Ah, so triggers are probably not suitable for the use cases that I'm thinking of then.

@mitchellh
Copy link
Contributor

Tagged as enhancement. I think this is a good idea. Instead of just Ruby, any shell script is probably a good idea.

@mitchellh mitchellh added the core label Oct 24, 2014
@snowch
Copy link
Author

snowch commented Oct 25, 2014

It would be good to be able to execute any type of script, but I guess the main benefit of ruby over other shell scripts is that vagrant comes with an embedded ruby environment so you can guarantee your ruby script will always work on all host without having to install any other script interpreters.

@sethvargo sethvargo changed the title Enhancement: allow vagrant to execute ruby scripts on host Allow vagrant to execute scripts on host Dec 13, 2014
@sethvargo
Copy link
Contributor

Hi all,

You can use Vagrant's embedded Ruby which lives at /opt/vagrant/embedded/bin/ruby to run scripts. For bash, bat, and other shell provisioners, unfortunately the system will just need to make that environment available.

While we could expose this as a command, I don't think we want to encourage users to rely on Vagrant's internal language over time. While it's true that Vagrant is written in Ruby and packages a Ruby environment, I don't think we want to tie ourselves to that promise at this time. Thanks! 😄

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants