elaborate on a couple of sections
This commit is contained in:
parent
461afa2b25
commit
fb3d5d6589
1 changed files with 28 additions and 13 deletions
|
@ -19,13 +19,17 @@ This guide will describe how to use Vagrant and Ansible together.
|
||||||
If you're not familar with Vagrant, you should visit `the documentation
|
If you're not familar with Vagrant, you should visit `the documentation
|
||||||
<http://docs.vagrantup.com/v2/>`_.
|
<http://docs.vagrantup.com/v2/>`_.
|
||||||
|
|
||||||
|
This guide assumes that you already have Ansible installed and working.
|
||||||
|
Running from a Git checkout is fine. Follow the :doc:`intro_installation`
|
||||||
|
guide for more information.
|
||||||
|
|
||||||
.. _vagrant_setup:
|
.. _vagrant_setup:
|
||||||
|
|
||||||
Vagrant Setup
|
Vagrant Setup
|
||||||
`````````````
|
`````````````
|
||||||
|
|
||||||
The first step once you've installed Vagrant is to create a Vagrantfile and
|
The first step once you've installed Vagrant is to create a ``Vagrantfile``
|
||||||
customize it to suit your needs. This is covered in detail in the Vagrant
|
and customize it to suit your needs. This is covered in detail in the Vagrant
|
||||||
documentation, but here is a quick example:
|
documentation, but here is a quick example:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
@ -55,8 +59,8 @@ example that includes a section to use the Ansible provisioner:
|
||||||
end
|
end
|
||||||
|
|
||||||
The Vagrantfile has a lot of options, but these are the most important ones.
|
The Vagrantfile has a lot of options, but these are the most important ones.
|
||||||
Notice the "config.vm.provision" section that refers to an Ansible playbook
|
Notice the ``config.vm.provision`` section that refers to an Ansible playbook
|
||||||
called "playbook.yml" in the same directory as the Vagrantfile. Vagrant runs
|
called ``playbook.yml`` in the same directory as the Vagrantfile. Vagrant runs
|
||||||
the provisioner once the virtual machine has booted and is ready for SSH
|
the provisioner once the virtual machine has booted and is ready for SSH
|
||||||
access.
|
access.
|
||||||
|
|
||||||
|
@ -66,24 +70,35 @@ access.
|
||||||
|
|
||||||
This will start the VM and run the provisioning playbook.
|
This will start the VM and run the provisioning playbook.
|
||||||
|
|
||||||
There are a lot of Ansible options you can configure in your Vagrantfile.
|
There are a lot of Ansible options you can configure in your Vagrantfile. Some
|
||||||
|
particularly useful options are ``ansible.extra_vars``, ``ansible.sudo`` and
|
||||||
|
``ansible.sudo_user``, and ``ansible.host_key_checking`` which you can disable
|
||||||
|
to avoid SSH connection problems to new virtual machines.
|
||||||
|
|
||||||
Visit the `Ansible Provisioner documentation
|
Visit the `Ansible Provisioner documentation
|
||||||
<http://docs.vagrantup.com/v2/provisioning/ansible.html>`_ for more
|
<http://docs.vagrantup.com/v2/provisioning/ansible.html>`_ for more
|
||||||
information.
|
information.
|
||||||
|
|
||||||
|
To re-run a playbook on an existing VM, just run:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ vagrant provision
|
||||||
|
|
||||||
|
This will re-run the playbook.
|
||||||
|
|
||||||
.. _running_ansible:
|
.. _running_ansible:
|
||||||
|
|
||||||
Running Ansible Manually
|
Running Ansible Manually
|
||||||
````````````````````````
|
````````````````````````
|
||||||
|
|
||||||
You can re-run the Ansible playbook for your Vagrant machine by running
|
Sometimes you may want to run Ansible manually against the machines. This is
|
||||||
"vagrant provision", but sometimes you may want to run Ansible manually
|
pretty easy to do.
|
||||||
against the machines. This is pretty easy to do.
|
|
||||||
|
|
||||||
Vagrant automatically creates an inventory file for each Vagrant machine in
|
Vagrant automatically creates an inventory file for each Vagrant machine in
|
||||||
the same directory called "vagrant_ansible_inventory_machinename". It
|
the same directory called ``vagrant_ansible_inventory_machinename``. It
|
||||||
configures the inventory file according to the SSH tunnel that Vagrant
|
configures the inventory file according to the SSH tunnel that Vagrant
|
||||||
automatically creates, and executes "ansible-playbook" with the correct
|
automatically creates, and executes ``ansible-playbook`` with the correct
|
||||||
username and SSH key options to allow access. A typical automatically-created
|
username and SSH key options to allow access. A typical automatically-created
|
||||||
inventory file may look something like this:
|
inventory file may look something like this:
|
||||||
|
|
||||||
|
@ -94,9 +109,9 @@ inventory file may look something like this:
|
||||||
machine ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
|
machine ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
|
||||||
|
|
||||||
If you want to run Ansible manually, you will want to make sure to pass
|
If you want to run Ansible manually, you will want to make sure to pass
|
||||||
"ansible" or "ansible-playbook" the correct arguments for the username
|
``ansible`` or ``ansible-playbook`` commands the correct arguments for the
|
||||||
(usually "vagrant") and the SSH key (usually
|
username (usually ``vagrant``) and the SSH key (usually
|
||||||
"~/.vagrant.d/insecure_private_key"), and the autogenerated inventory file.
|
``~/.vagrant.d/insecure_private_key``), and the autogenerated inventory file.
|
||||||
|
|
||||||
Here is an example:
|
Here is an example:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue