DEV Community

Cover image for Get a practice Ansible Lab in 1 step -- Powered by Docker
Stanley Chinedu Ogada
Stanley Chinedu Ogada

Posted on • Edited on

5 2 2 2 3

Get a practice Ansible Lab in 1 step -- Powered by Docker

Table of Contents

  1. Why This Project?
  2. Project Goals
  3. Documentation
  4. Conclusion and Useful Links

Why This Project?

The motivation behind this Docker Ansible Lab project is to eliminate the headaches associated with creating a lab environment for Ansible practice. The traditional setup demands a robust machine capable of running at least three VMs, with various configurations such as network establishment and SSH communication. This project aims to simplify the process by allowing users to set up a scalable lab environment within Docker, with minimal configuration requirements.

Project Goals

The primary goal of the Docker Ansible Lab project is to enable users to effortlessly set up a lab environment within a Docker container. Unlike traditional setups, this project offers scalability, allowing users to create more than three machines with ease. The emphasis here is on minimizing the setup steps and allowing users to dive straight into Ansible without worrying about the intricacies of lab configuration.

Documentation

Docker Ansible Lab Configuration

Note: This configuration will create a total of five nodes, including three Ubuntu and two Oracle Linux machines. Refer to the docker-compose.yaml file for details.

Node Credentials:

  • Username: zero
  • Password: ][poiuy

Prerequisites

Before getting started, ensure the following prerequisites are met:

  • Docker installed on your machine
  • Docker Compose installed
  • Docker daemon started
  • For Ubuntu, consider adding your user to the docker group
  • Optionally, install the provided version (refer to the screenshot below) of higher

Docker Ansible Setup

Usage Instructions

  1. Clone the repository and navigate to it.
  2. Run docker-compose up -d.
  3. View the logs using docker-compose logs -f.
  4. Wait for approximately 1-5 minutes until you see a message indicating "SUCCESS! ... Happy hacking!"
  5. Your Ansible lab is now ready!

Control-Host Usage

  1. Open a new terminal for each control host.
  2. Run docker container exec -it control-host bash.
  3. Stay as the root user.
  4. In the container, navigate to cd ~/ansible-project as this is your base Ansible directory.
  5. Your lab is ready! You can now control and configure all servers. Test server connections with ansible all -m ping.

Server Usage (Example for Server-1)

  1. Open a new terminal for each server.
  2. Run docker container exec -it server-1 bash.
  3. Switch to the zero user by running su - zero and use the password \][poiuy.

Conclusion and Useful Links

Simplify your Ansible learning journey with this Docker Ansible Lab setup, and enjoy a seamless and scalable environment for honing your skills. For further engagement, you can connect with me on LinkedIn. Additionally, explore the project on GitHub for more details and updates (Please star this project 🙏 ). Happy hacking!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️