Ansible/Vagrant/Static Inventory: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{Main|Ansible/Vagrant}} | {{Main|Ansible/Vagrant}} | ||
This page covers how to manage a static inventory file (a.k.a., hosts file, [[Ansible/Hosts]]) for Ansible, maintained by hand, if you are using Ansible with | This page covers how to manage a static inventory file (a.k.a., hosts file, [[Ansible/Hosts]]) for Ansible, maintained by hand, if you are using [[Ansible]] with [[Vagrant]]. | ||
==Static vs dynamic inventory== | ==Static vs dynamic inventory== | ||
Revision as of 04:20, 11 November 2018
This page covers how to manage a static inventory file (a.k.a., hosts file, Ansible/Hosts) for Ansible, maintained by hand, if you are using Ansible with Vagrant.
Static vs dynamic inventory
Ansible/Vagrant/Static Inventory - static inventory requires the hosts file (containing the list of machines that Ansible is managing) be kept up to date by hand. This can be a burden if details are changing or if things are allocated automatically.
Ansible/Vagrant/Dynamic Inventory - dynamic inventory uses something like an API or a database to obtain information about the machines that Ansible is managing. This makes scaling and generalization much easier.
Managing a static inventory file using Vagrant boxes
Edit playbooks/hosts and include details about each vagrant host.
Use the command vagrant ssh-config to get these details.
Example:
$ cat playbooks/hosts myvagrantbox ansible_host=127.0.0.1 ansible_port=2222 ansible_user=vagrant ansible_private_key_file=.vagrant/machines/default/virtualbox/private_key
Your vagrant boxes should be up and running with the vagrant up command.