This project sets up a lab environment with three endpoints (servers) and a workstation using Vagrant. The lab is designed for Ansible testing and practice, providing a controlled environment to work with Ansible playbooks, modules, and automation tasks.
This lab environment contains:
- Workstation: A VM where you will run Ansible commands.
- 3 Endpoints (servers): Three VMs acting as target servers for Ansible automation.
The environment uses Vagrant to automate the creation of these VMs, which are then connected for testing Ansible roles, playbooks, and configurations.
- Workstation: The workstation serves as the control node for Ansible.
- Endpoints: The three servers serve as target machines for Ansible commands.
You will log into the workstation to execute Ansible commands against the three servers.
-
Workstation VM:
- Username:
student
- Password:
student
- Username:
-
Endpoints 1, 2 & 3 (servers):
- Username:
ansible
- Password:
ansible
- Username:
Before setting up the lab, ensure you have the following installed:
- Vagrant: Install Vagrant
- VirtualBox: Install VirtualBox (or any other Vagrant provider)
- Ansible: Install Ansible (optional, if not using the preconfigured Vagrant environment)
-
Clone the Repository:
git clone <repository-url> cd ansible_lab
-
Start the Environment:
Run the following command to bring up the Vagrant environment:
vagrant up
This will automatically create and configure the three endpoint VMs and the workstation VM.
-
SSH into the Workstation:
Once the VMs are up, SSH into the workstation to start testing:
vagrant ssh workstation
-
Running Ansible Playbooks: From the workstation, you can execute Ansible commands and playbooks against the three endpoints.
Example: Run the Ansible
ping
module to check connectivity:ansible all -m ping
-
Inventory File: The inventory for Ansible should be configured to include the three endpoints. This will be located on the workstation.
Example inventory (/etc/ansible/hosts):
[servers] endpoint1 ansible_host=192.168.50.4 ansible_user=ansible endpoint2 ansible_host=192.168.50.5 ansible_user=ansible endpoint3 ansible_host=192.168.50.6 ansible_user=ansible
If Vagrant fails to start the environment, try running:
vagrant destroy -f && vagrant up
To stop and remove the environment:
vagrant halt
vagrant destroy
Enjoy practicing Ansible with this controlled lab setup!