Custom cleanup on Ctrl-C interruption of vagrant provision

98 views
Skip to first unread message

Rob Ots

unread,
Nov 15, 2018, 1:53:50 PM11/15/18
to Vagrant
I have a provisioning step that does a Powershell Start-Process. If the vagrant provision is interrupted with Ctrl-C, that leaves the process continuing on the guest VM. Is there possibly a way to specify a custom cleanup step that would get called if provisioning is Ctrl-C interrupted (to ensure those processes are killed)?

Rob Ots

unread,
Nov 15, 2018, 2:04:59 PM11/15/18
to Vagrant
More information: I had tried using a try-finally mechanism in the provisioning Powershell script. That does seem to call the finally block on Ctrl-C interrupting the vagrant provision if the guest VM has Powershell 2, but does not seem to when the guest VM has Powershell 5. Is there possibly an equivalent try-finally mechanism available at the vagrant provision level?

Alvaro Miranda Aguilera

unread,
Nov 15, 2018, 3:32:35 PM11/15/18
to vagra...@googlegroups.com
without vagrant

if you run and cancel a powershell script what happens?

whats the vagrantfile code you are usin to run this script?

is there a way to run a powershell in debug/trace to see what happens when you cancel ?

in bash you can use `set -x` 

thanks
alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/25d0eb0e-286b-4aaa-b2a5-fea5374de75f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Reply all
Reply to author
Forward
0 new messages