Ansible - 2 - 1 Insttallation virtual box
To practise Ansible from scratch we need a small lab on our own machine. The plan is to use VirtualBox, a free virtualisation tool that runs on Windows, Linux and macOS. The exact host OS does not matter — the steps below work identically on any of them. The example uses Windows.
VirtualBox and a CentOS template
Download the VirtualBox installer from virtualbox.org, run the executable and follow the installation wizard. Once VirtualBox is open we need a Linux machine to clone. Instead of installing CentOS from an ISO, we grab a ready-to-use disk image from osboxes.org: head to VM Images > VirtualBox Images, pick the CentOS 64-bit build and extract the resulting .vdi file with 7-Zip or WinRAR.
- Create a new VM in VirtualBox, name it
centos-template, type Linux and version Other Linux (64-bit). - Allocate 2 GB of RAM and select Use an existing virtual hard disk file, pointing to the extracted
.vdi. - Before booting, raise the video memory to 16 MB and change the network adapter to Bridged.
Power on the VM, log in as user osboxes with the default password (visible on the osboxes.org info page), and run ifconfig to read the IP address allocated by DHCP. From your host, connect to the VM using an SSH client such as MobaXterm: a new SSH session, the IP we just read, username osboxes, password from osboxes, and we land on a shell. Once we can SSH in successfully we shut the template down — it is now ready to be cloned into the multiple VMs we will need in the upcoming lessons.
Summary
This lesson covers the complete setup of a VirtualBox environment for Ansible infrastructure automation. You'll learn how to download and install VirtualBox, create a base template virtual machine using pre-built CentOS disk images, and configure multiple virtual machines for Ansible control and target nodes. The lesson demonstrates the practical approach of creating a reusable template from which you can easily deploy multiple VMs for testing Ansible playbooks and configurations.
Key points
- Download VirtualBox from the official site and execute the installer following the installation wizard instructions
- Use pre-built VM images from osboxes.org (e.g., CentOS) rather than installing from scratch—these come pre-configured and require decompression before use
- Create a template virtual machine with sufficient resources (2 GB RAM, 2 CPU cores recommended) that can be cloned to quickly deploy control and target nodes
- Configure network adapters to bridge mode to enable internet connectivity for the virtual machine to download and install packages
- Verify the virtual machine is running and obtain its IP address using network configuration commands for SSH access
FAQ
What are the prerequisites for following this Ansible VirtualBox setup lesson?
You need a Windows, Linux, or macOS system with sufficient disk space and RAM to run virtual machines. VirtualBox is cross-platform and works the same way on all operating systems, though specific installer versions differ based on your host OS.
Why use pre-built VM images instead of installing CentOS from scratch?
Pre-built images from osboxes.org come pre-configured and pre-installed, saving significant setup time. You simply extract the VMDK file and use it as your virtual disk, rather than going through the entire OS installation process.
How do I create multiple Ansible nodes from the template machine?
Once the template virtual machine is created and configured, you can easily clone it to generate additional control and target machines for your Ansible lab environment, each inheriting the base configuration and allowing you to test playbooks across multiple nodes.