Quick Start Guide¶
This document will show you how to get up and running with this multi node Vagrant environment. If you are not familiar with Vagrant, then you should read the Vagrant Documentation too.
Requirements¶
This setup was tested under Windows 10 with the following components:
- VirtualBox = 6.0.14
- Vagrant = 2.2.6
- Ansible = 2.8.2 within Cygwin 2.10.0, see Jeff Geerling's Blog to Running Ansible within Windows
and under Ubuntu 16.04 LTS (Xenial Xerus) and Ubuntu 18.04 LTS (Bionic Beaver) with:
preinstalled.
Note
This document does not explain how to install these components. You have to do it yourself by reading the installation guides of these components.
Get the Vagrant Environment¶
For the next steps open a bash (under Windows a cygwin bash) on the virtual host system.
Download Vagrant box configuration¶
git clone https://gitlab.com/cogline_vagrant/ansible-development.git
cd ansible-development
Get Ansible roles for provisioning¶
Now install Ansible roles defined under provisioning/requirements.yml
:
ansible-galaxy install -r provisioning/requirements.yml -p provisioning/roles
Install vagrant plugins¶
Before using this Vagrant environment, you still need to install the following plugins.
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-hostmanager
If you use Vagrant with libvirt under Linux, you also need to install the following plugins
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-mutate
# on Debian/Ubuntu systems
sudo apt install -y nfs-kernel-server
# on Enterprise Linux (CentOS/RedHat)
sudo yum -y install nfs-utils
Define Ansible Client(s)¶
Your Ansible development environment requires at least one virtual machine
(Vagrant box) with a supported operating system.
Open the file boxes.yml
and enter your Ansible clients here, e.g.:
boxes.yml
---
- image: generic/centos8
start: true
hostname: el8-node
vbox_name: 'EL8 - Node'
nodes: 3
- image: generic/debian10
start: true
hostname: debian-buster-node
vbox_name: 'Debian (Buster) - Node'
nodes: 1
This will start three nodes with CentOS 8 and one node with Debian Buster. See
section "Define Vagrant Boxes" for more
details on configuring the boxes.yml
file.
Initial Provisioning¶
The next step will start all Ansible Clients and the Ansible management node. While starting the first time Vagrant will be run any configured provisioners against the running managed machines.
This will take a few minutes
The first time this step takes a while. All required Vagrant Boxes will be downloaded from the Vagrant Cloud. Depending on the speed of your internet connection, this will take a few minutes. Subsequently, the individual systems are started and provisioned in sequence. Then the environment is ready for the development and testing of new Ansible playbooks and roles.
Provisioning with provider VirtualBox¶
The Vagrant environment can be started with the provider VirtualBox as follows.
vagrant up
Provisioning with provider libvirt¶
If you want to use vagrant with libvirt instead of VirtualBox, use
VAGRANT_DEFAULT_PROVIDER=libvirt vagrant up --no-parallel
libvirt: Switch off the parallel installation the first time
The provider libvirt usually performs the installation of virtual machines
in parallel. It happens that Ansible Provisioner is running on the master
node before all Ansible clients are up and running. Therefore, the Ansible
Provisioner sometimes can not reach all clients through SSH from the master
node, and Ansible fails for the affected clients. That's why when starting
the environment for the first time, the parallel installation should be
suppressed using the vagrant option --no-parallel
.
If you have not turned off the parallel installation and the Ansible provisioner fails, then the provisioning on the master node can be re-executed with the following command after all clients are up and running.
VAGRANT_DEFAULT_PROVIDER=libvirt vagrant provision master