Add basic triggers example

This commit is contained in:
Brian Cain 2018-04-05 14:19:35 -07:00
parent 6f2b5a9fa0
commit 5e9387dca8
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
1 changed files with 23 additions and 0 deletions

View File

@ -12,6 +12,29 @@ Below are some very simple examples of how to use Vagrant Triggers.
## Examples
The following is a basic example of two global triggers. One that runs _before_
the `:up` command and one that runs _after_ the `:up` command:
```ruby
Vagrant.configure("2") do |config|
config.trigger.before :up do |trigger|
trigger.name = "Hello world"
trigger.info = "I am running before vagrant up!!"
end
config.trigger.before :up do |trigger|
trigger.name = "Hello world"
trigger.info = "I am running after vagrant up!!"
end
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.box = "ubuntu"
end
end
```
These will run before and after each defined guest in the Vagrantfile.
Running a remote script to save a database on your host before __destroy__ing a
guest: