Skip to content

guillermodotn/Ansible_lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Lab

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.

Table of Contents

Overview

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.

Lab Setup

  1. Workstation: The workstation serves as the control node for Ansible.
  2. 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.

System Details

  • Workstation VM:

    • Username: student
    • Password: student
  • Endpoints 1, 2 & 3 (servers):

    • Username: ansible
    • Password: ansible

Prerequisites

Before setting up the lab, ensure you have the following installed:

Installation

  1. Clone the Repository:

    git clone <repository-url>
    cd ansible_lab
  2. 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.

  3. SSH into the Workstation:

    Once the VMs are up, SSH into the workstation to start testing:

    vagrant ssh workstation

Usage

  • 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

Troubleshooting

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!