This requires editing the local system's hosts files. I am trying to avoid
that scenario and create a Vagrant + Ansible environment that works on any
system (no hosts file needed) w/o need for root access, and I wanted to
plug in the appropriate information to simulate a real world environment
where users would have a DNS server that correspond to the inventory file.
To do this, I wanted to custom generate an inventory file on the fly, using
the current ssh configuration.
My Vagrant would look something like this:
config.vm.hostname = "wheezybox"
config.vm.provision :ansible do |ansible|
ansible.playbook = "../../provisioning/playbook.yml"
# ansible.inventory_path = "../../provisioning/inventory.ini"
ansible.sudo = true
end
I would like to have code before the # comment.
In deep diving into Vagrant 1.7.4 code, I can see there's some
*machine.ssh_info*, but I don't know how to get at this.
On Monday, August 3, 2015 at 11:37:24 PM UTC-7, Alvaro Miranda Aguilera
wrote:
>
> Hello
>
> Can you check these examples?
>
> Since they don't require anything special:
>
> # Enable provisioning with Ansible.
> config.vm.provision "ansible" do |ansible|
> ansible.playbook = "provisioning/main.yml"
> end
>
>
>
> https://github.com/geerlingguy/ansible-vagrant-examples/blob/master/docker/Vagrantfile
>
>
>
>
> On Tue, Aug 4, 2015 at 6:17 PM, Joaquin Menchaca <[email protected]
> <javascript:>> wrote:
> > Hello.
> >
> > I wanted to do host base configuration using hostname, and then
> dynamically
> > populating inventory file with appropriate guest SSH port and private
> key
> > path.
> >
> > Vagrant Ansible Provisioner doesn't work if you rely on it to
> auto-generate
> > the inventory file, as it uses 127.0.0.1 for hostname. For example,
> it'll
> > create a file /path/to/vagrant/.vagrant/provisioners/ansible/inventory/:
> >
> > default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200
> >
> ansible_ssh_private_key_file=/path/to/vagrantdir/.vagrant/machines/default/virtualbox/private_key
>
>
> >
> > I tried experimenting retrieving values (newbie working with vagrant
> ruby
> > code), testing something like
> >
> > puts "config.ssh.private_key_path=#{config.ssh.private_key_path}"
> > puts "config.ssh.guest_port=#{config.ssh.guest_port}"
> >
> > But his returns objects, and I am not sure what to do. Any suggestions?
> >
> > --
> > 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 [email protected] <javascript:>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/vagrant-up/a7036744-42ff-4f66-b650-54e94a3b63cb%40googlegroups.com.
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/2bce9691-b844-48f6-9c44-9c0fdbe1319d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.