From 1cd2fe56a0cbcf65196d86fce215d48019e29b51 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 24 Feb 2014 16:52:38 +0100 Subject: [PATCH] ansible: generate inventory in .vagrant/... --- plugins/provisioners/ansible/provisioner.rb | 5 +++-- website/docs/source/v2/provisioning/ansible.html.md | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index d10fad7b8..f665fdb4a 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -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") diff --git a/website/docs/source/v2/provisioning/ansible.html.md b/website/docs/source/v2/provisioning/ansible.html.md index eb10b796d..cf0d5d067 100644 --- a/website/docs/source/v2/provisioning/ansible.html.md +++ b/website/docs/source/v2/provisioning/ansible.html.md @@ -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