Switch to Vagrant-generated Ansible inventory

Remove `hosts`. Update `Vagrantfile` to not generate hosts file.
Update `ansible.cfg` to use Vagrant-generated Ansible inventory
file.
This commit is contained in:
Scott Lowe 2016-01-10 19:57:12 -07:00
parent 4f2155d6ee
commit 52eb89ab29
4 changed files with 2 additions and 13 deletions

View file

@ -4,9 +4,7 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
## Contents
* **ansible.cfg**: This Ansible configuration file instructs Ansible to use an inventory file named `hosts` in the current directory, and to use the default vagrant user (`vagrant`) and default insecure Vagrant SSH private key.
* **hosts**: This file is created automatically when you run `vagrant status` or `vagrant up` (anytime Vagrant processes the `Vagrantfile`). This file relies on the presence of a "ip_addr" value in `machines.yml`. Do not edit this file directly---instead edit `machines.yml` to change the values that will be automatically written into this file.
* **ansible.cfg**: This Ansible configuration file instructs Ansible to use an inventory file named `hosts` in the current directory, to use the default vagrant user (`vagrant`) and default insecure Vagrant SSH private key, and to use the Vagrant-generated Ansible inventory file (found, by default, in `./vagrant/provisioners/inventory/vagrant_ansible_inventory`).
* **machines.yml**: This YAML file contains a list of VM definitions and associated configuration data. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. Generally the only change this file needs is to ensure the "box" value correctly references the Vagrant box you're using. The "ip_addr" value is also required in order to build the Ansible inventory file; you may want to edit this to a value appropriate for your environment.

8
lxc/Vagrantfile vendored
View file

@ -15,14 +15,6 @@ require 'yaml'
# Read YAML file with VM details (box, CPU, and RAM)
machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml'))
# Create Ansible inventory file
# (current contents will be overwritten)
f = File.open('hosts','w')
machines.each do |machine|
f.puts machine['ip_addr']
end # machines.each
f.close
# Create and configure the VMs
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

View file

@ -1,5 +1,5 @@
[defaults]
inventory = ./hosts
inventory = ./vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
private_key_file = ~/.vagrant.d/insecure_private_key
remote_user = vagrant
host_key_checking = False

View file

@ -1 +0,0 @@
192.168.100.100