ansible: generate inventory in .vagrant/...

This commit is contained in:
Gilles Cornu 2014-02-24 16:52:38 +01:00
parent d5055c6252
commit 1cd2fe56a0
2 changed files with 4 additions and 4 deletions

View File

@ -71,8 +71,9 @@ module VagrantPlugins
# Managed machines
inventory_machines = {}
generated_inventory_file =
@machine.env.root_path.join("vagrant_ansible_inventory")
generated_inventory_dir = @machine.env.local_data_path.join(File.join(%w(provisioners ansible inventory)))
FileUtils.mkdir_p(generated_inventory_dir) unless File.directory?(generated_inventory_dir)
generated_inventory_file = generated_inventory_dir.join('vagrant_ansible_inventory')
generated_inventory_file.open('w') do |file|
file.write("# Generated by Vagrant\n\n")

View File

@ -33,8 +33,7 @@ there are two ways to approach working with inventory files.
The first and simplest option is to not provide one to Vagrant at all. Vagrant will generate an
inventory file encompassing all of the virtual machine it manages, and use it for provisioning
machines. The generated inventory file is created adjacent to your Vagrantfile, named
`vagrant_ansible_inventory`.
machines. The generated inventory file is stored as part of your local Vagrant environment in `.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory`.
The `ansible.groups` option can be used to pass a hash of group
names and group members to be included in the generated inventory file. Group variables