mitchellh/vagrant — pull request #2926 by maspwr (2014-02-01 21:19:01+00:00)
Title: Update Ansible provisioner to only create a single inventory file

The Ansible provisioner will now only create a single inventory file named,
"vagrant_ansible_inventory". All defined Vagrant machines will be added to
this inventory file. Provisioning will now include a "--limit=#{machine}"
option to scope Ansible provisioning tasks to just the current machine. Setting
the Ansible provisioner's "limit" config option will override the new default
limit. Ansible provisioning scripts will now have access to all other defined
machines and what groups they reside in.

An example Vagrantfile and playbook to test these changes:

```ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu_saucy"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"

config.vm.define "machinea" do |machinea|
end

config.vm.define "machineb" do |machinea|
end

config.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant.yml"
ansible.verbose = "v"
ansible.host_key_checking = false
#ansible.limit = ""
ansible.groups = {
"foo_group" => ["machinea"],
"bar_group" => ["machineb"],
"all_groups:children" => ["foo_group", "bar_group"],
"not_included:children" => ["sad_group"]
}
end
end
```

```
---
- hosts: foo_group
tasks:
- name: Testing foo
command: echo foo

- hosts: bar_group
tasks:
- name: Testing bar
command: echo bar
```