emyl / vagrant-triggers

Allow the definition of arbitrary scripts that will run on the host before and/or after Vagrant commands.
MIT License
546 stars 35 forks source link

More Examples Please #20

Closed jamiejackson closed 10 years ago

jamiejackson commented 10 years ago

I'm having trouble doing some simple things, both because I'm a Ruby noob, and because I can find only two vagrant-triggers examples on the internet (and their syntaxes seem to conflict).

Could you provide an example for, say:

emyl commented 10 years ago

Hi!

I've added a simple example for running a command after vagrant destroy to README: https://github.com/emyl/vagrant-triggers#a-simple-example

You can also embed some inline ruby, a quick example could be:

config.trigger.before :up do
  random_number = Random.rand(100)
  info "Number drawn: ${random_number}"
end

Keep in mind that your ruby code will always run in the context of an instance of the DSL class.