I would have to do something like this:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "chef/centos-6.6" # Get CentOS6 From Somewhere
  config.vm.hostname = "centos6box" # Give System a Hostname

  # Retreive and Configure Default SSH host port
  ssh_port = 
open('../../provisioning/vagrant.ini').grep(/#{config.vm.hostname}/)[0].split(/[=\s]/)[4]
  config.vm.network :forwarded_port, guest: 22, host: ssh_port, id: "ssh"

  # Provision System
  config.vm.provision :ansible do |ansible|
     ansible.limit = config.vm.hostname
     ansible.playbook = "../../provisioning/playbook.yml"
     ansible.inventory_path = "../../provisioning/vagrant.ini"
     ansible.sudo = true
  end
end

My vagrant.ini looks like this.

[scriptbox]
centos6box ansible_ssh_host=127.0.0.1 ansible_ssh_port=3222 
ansible_ssh_private_key_file=vagrants/centos6/.vagrant/machines/default/virtualbox/private_key
wheezybox  ansible_ssh_host=127.0.0.1 ansible_ssh_port=3223 
ansible_ssh_private_key_file=vagrants/wheezy/.vagrant/machines/default/virtualbox/private_key
precisebox ansible_ssh_host=127.0.0.1 ansible_ssh_port=3224 
ansible_ssh_private_key_file=vagrants/precise/.vagrant/machines/default/virtualbox/private_key

And my directory structure.

.
├── README.md
├── provisioning
│   ├── inventory
│   ├── playbook.yml
│   ├── tasks
│   │   ├── Debian.yml
│   │   └── RedHat.yml
│   ├── vagrant.ini
│   └── vars
│       └── main.yml
└── vagrants
    ├── centos6
    │   └── Vagrantfile
    ├── precise
    │   └── Vagrantfile
    └── wheezy
        └── Vagrantfile

-- 
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/4f321aa5-4628-417a-bdf8-91983033d6af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to