Skip to content

Commit f1c6576

Browse files
doc changes
1 parent c70e8ab commit f1c6576

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

website/content/docs/triggers/usage.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ running either `vagrant destroy` or `vagrant halt` would stop tinyproxy.
9696

9797
Triggers can also be defined to run Ruby, rather than bash or PowerShell. An
9898
example of this might be using a Ruby option to get more information from the `VBoxManage`
99-
tool. In this case, we are printing the `ostype` defined for thte guest after
99+
tool. In this case, we are printing the `ostype` defined for the guest after
100100
it has been brought up.
101101

102102
```ruby
@@ -196,3 +196,46 @@ config.trigger.before :"Vagrant::Action::Builtin::GracefulHalt", type: :action d
196196
t.warn = "Vagrant is halting your guest..."
197197
end
198198
```
199+
200+
#### Provision action
201+
202+
The provision stack works little different than the other action stacks. The Vagrant
203+
stack is made up of middlewares that are run in a specific order. generally it tend to
204+
to perform their operation and call to the next item but in some cases will continue to
205+
do things once the next item completes. In the Provision action, the next item in the
206+
stack is executed [here](https://github.com/hashicorp/vagrant/blob/main/lib/vagrant/action/builtin/provision.rb#L82-L83).but the actual provisioning happens at the end [here](https://github.com/hashicorp/vagrant/blob/main/lib/vagrant/action/builtin/provision.rb#L129-L133), after the rest of the stack
207+
has executed and exited.
208+
209+
210+
```
211+
Vagrant.configure("2") do |config|
212+
config.vm.box = "ubuntu"
213+
214+
# Provisioners:
215+
config.vm.provision "PROVISIONER1", type: :shell, inline: "echo executing first provisioner"
216+
config.vm.provision "PROVISIONER2", type: :shell, inline: "echo executing second provisioner"
217+
218+
# Triggers:
219+
220+
config.trigger.before :machine_action_provision, type: :hook,
221+
name: "HOOK TRIGGER BEFORE machine_action_provision",
222+
info: "INSIDE BEFORE machine_action_provision HOOK TRIGGER"
223+
224+
config.trigger.before Vagrant::Action::Builtin::Provision, type: :action,
225+
name: "ACTION TRIGGER BEFORE Vagrant::Action::Builtin::Provision",
226+
info: "INSIDE BEFORE Vagrant::Action::Builtin::Provision TRIGGER"
227+
228+
config.trigger.after Vagrant::Action::Builtin::Provision, type: :action,
229+
name: "ACTION TRIGGER AFTER Vagrant::Action::Builtin::Provision",
230+
info: "INSIDE AFTER Vagrant::Action::Builtin::Provision TRIGGER"
231+
232+
config.trigger.after :machine_action_provision, type: :hook,
233+
name: "HOOK TRIGGER AFTER machine_action_provision",
234+
info: "INSIDE AFTER machine_action_provision HOOK TRIGGER"
235+
236+
end
237+
```
238+
239+
When running `vagrant provision` or `vagrant up`, the before and after triggers
240+
will run before the provisioning of the box happens.
241+

0 commit comments

Comments
 (0)