-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Provision action trigger ordering with provision action #13690
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
Open
anshulsharma-hashicorp
wants to merge
1
commit into
main
Choose a base branch
from
anshul/issue_13468
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ running either `vagrant destroy` or `vagrant halt` would stop tinyproxy. | |
|
||
Triggers can also be defined to run Ruby, rather than bash or PowerShell. An | ||
example of this might be using a Ruby option to get more information from the `VBoxManage` | ||
tool. In this case, we are printing the `ostype` defined for thte guest after | ||
tool. In this case, we are printing the `ostype` defined for the guest after | ||
it has been brought up. | ||
|
||
```ruby | ||
|
@@ -196,3 +196,46 @@ config.trigger.before :"Vagrant::Action::Builtin::GracefulHalt", type: :action d | |
t.warn = "Vagrant is halting your guest..." | ||
end | ||
``` | ||
|
||
#### Provision action | ||
|
||
The provision stack works little different than the other action stacks. The Vagrant | ||
stack is made up of middlewares that are run in a specific order. generally it tend to | ||
to perform their operation and call to the next item but in some cases will continue to | ||
do things once the next item completes. In the Provision action, the next item in the | ||
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 | ||
has executed and exited. | ||
|
||
|
||
``` | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = "ubuntu" | ||
|
||
# Provisioners: | ||
config.vm.provision "PROVISIONER1", type: :shell, inline: "echo executing first provisioner" | ||
config.vm.provision "PROVISIONER2", type: :shell, inline: "echo executing second provisioner" | ||
|
||
# Triggers: | ||
|
||
config.trigger.before :machine_action_provision, type: :hook, | ||
name: "HOOK TRIGGER BEFORE machine_action_provision", | ||
info: "INSIDE BEFORE machine_action_provision HOOK TRIGGER" | ||
|
||
config.trigger.before Vagrant::Action::Builtin::Provision, type: :action, | ||
name: "ACTION TRIGGER BEFORE Vagrant::Action::Builtin::Provision", | ||
info: "INSIDE BEFORE Vagrant::Action::Builtin::Provision TRIGGER" | ||
|
||
config.trigger.after Vagrant::Action::Builtin::Provision, type: :action, | ||
name: "ACTION TRIGGER AFTER Vagrant::Action::Builtin::Provision", | ||
info: "INSIDE AFTER Vagrant::Action::Builtin::Provision TRIGGER" | ||
|
||
config.trigger.after :machine_action_provision, type: :hook, | ||
name: "HOOK TRIGGER AFTER machine_action_provision", | ||
info: "INSIDE AFTER machine_action_provision HOOK TRIGGER" | ||
|
||
end | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Output of this should be included to display the behavior. |
||
|
||
When running `vagrant provision` or `vagrant up`, the before and after triggers | ||
will run before the provisioning of the box happens. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this true? |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated for grammar and clarity as it's mixing terms.