Create files programmatically during provision phase after "vagrant up --no-provision"

29 views
Skip to first unread message

Stathy Touloumis

unread,
Jan 26, 2016, 11:15:42 PM1/26/16
to Vagrant
Is there documentation as to how I can capture machine information that can be used during the provision process/scripts?

I'd like to create a hosts file based on a number of machines that come up and push the host file to all the machines during provisioning. So something like

vagrant up h1 h2 h3 --no-provision

vagrant provision h1 h2 h3
<do stuff based on configuration of the all the machines that have been setup>

Thanks,

Torben Knerr

unread,
Jan 27, 2016, 1:15:02 AM1/27/16
to vagra...@googlegroups.com

You may have a look at the vagrant-triggers plugin, this is probably what you are looking for.

Cheers, Torben

--
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/ec64b5a7-053e-4d0c-8859-43f4239d54c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Jan 27, 2016, 3:06:59 AM1/27/16
to vagra...@googlegroups.com
hello, you need host -> vm or vm -> vm communication?

if vm -> vm, have a look at Vagrant multi machine, you can set a fixed ip, and use that ip to create /etc/hosts updated

ie:

  #agent box
  (1..2).each do |i|
    vm_name = "agent#{i}"
    config.vm.define vm_name do |agent|
      agent.vm.box = "alvaro/oracle6-agent"
      agent.vm.hostname = vm_name
      agent.vm.network "public_network", ip: "192.168.10.#{10+i}"
      agent.vm.network "forwarded_port", guest: 80, host: 8000+i
    end
  end
This email has been sent from a virus-free computer protected by Avast.
www.avast.com

--

Stathy Touloumis

unread,
Jan 28, 2016, 10:21:27 AM1/28/16
to Vagrant
Thanks so much for the responses, I found the plugin with desire behavior at smdahlen / vagrant-hostmanager
Reply all
Reply to author
Forward
0 new messages