def machine_exists(vm_name) if get_machine_id(vm_name).nil? return false else return true endend
def get_machine_id(vm_name) machine_id_filepath = ".vagrant/machines/#{vm_name}/virtualbox/id" if not File.exists? machine_id_filepath return nil else return File.read(machine_id_filepath) endend
.
.
.
if machine_exists("server") server.ssh.username = "new-user"
server.ssh.private_key_path = ....
else server.trigger.after :up do |trigger| trigger.name = "Server reload trigger" trigger.info = "Server reload trigger" trigger.run = {inline: "vagrant reload server"} end end
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/f8c14015-856d-42de-99b1-6ecef5666b10%40googlegroups.com.
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/f8c14015-856d-42de-99b1-6ecef5666b10%40googlegroups.com.
--Brian Cain
Thanks for the fast reply.
So you are telling me that there is no way (beside my ugly workaround) to make a trigger fire only once after the initial creation of the machine?
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c323f046-ff44-4844-ae2f-16679e101dde%40googlegroups.com.