Usage
- There are several ways to run the Ansible Labs.
- Choose the method that works best for you.
Killercoda (Recommended)- 🐳 Docker
- 📜 From Source
Using Google Cloud Shell
- The easiest way to get started with the labs
- Learn Ansible in your browser without any local installation
Benefits:
- No installation required
- Pre-configured environment
- Works on any device with a web browser
- All tools pre-installed
Using Docker is the easiest way to get started locally with the labs:
# Change to the Labs directory
cd Labs/000-setup
# Run the setup lab using Docker Compose
docker-compose up -d
Prerequisites:
- Docker and Docker Compose installed on your system
- No additional setup required
For those who prefer to run it directly on their machine:
# Clone the repository
git clone https://github.com/nirgeier/AnsibleLabs.git
# Change to the Labs directory
cd AnsibleLabs/Labs
# Start with the setup lab
cd 000-setup
# Follow the instructions in the README of each lab
cat README.md
- Ansible installed on your system
- A Unix-like operating system (Linux, macOS, or Windows with WSL)
- Basic command-line tools
- Google Cloud Shell provides a free, browser-based environment with all necessary tools pre-installed.
- Click on the
Open in Google Cloud Shellbutton below:
- The repository will automatically be cloned into a free Cloud instance.
- Use CTRL + click to open it in a new window.
- Follow the instructions in the README of each lab.
Benefits:
- No local installation required
- Pre-configured environment
- Works on any device with a web browser
- All tools pre-installed
- Free tier available
Lab Breakdown
- If you choose to run the labs locally using Docker or From Source, follow the steps below to set up your environment.
- Make sure you have the necessary tools installed.
- Follow the instructions in the README of each lab.
- Review the Dockerfile(s) and docker-compose.yml for container configurations.
02. Build from source¶
- Clone the git repo:
- Navigate to the Labs directory:
-
Run the setup script:
Setup scripts breakdown:Script Content 🗞️ 00-build-containers.sh📒 Init the shared folders 🐳 Build the container(s) 🗞️ 01-init-servers.sh⏯ Initialize the containers 🔐 Extract the ssh certificates ✓ verify that the ssh service is running in the containers 🗞️ 02-init-ansible.sh🚀 Initialize the ansible files 📚 ansible.cfg📚 ssh.config📚 inventory -
The lab contains a
docker-composefile alongside a Dockerfile. - The containers are based on Ubuntu OS and are published on
DockerHubas well. - Build the demo containers by running:
- The docker-compose will create
ansible-controllerwhich will server as our controller to execute ansible playbooks on our demo servers defined by the nameslinux-server-X
Labs containers
| Container | Content |
|---|---|
🐳 ansible-controller | Linux container with ansible installed |
🐳 linux-server-1 | Linux container with ssh only (no ansible installed) |
🐳 linux-server-2 | Linux container with ssh only (no ansible installed) |
🐳 linux-server-3 | Linux container with ssh only (no ansible installed) |
- For the demo we will also need a shared folder(s) where the certificates and the configuration will be stored
- The shared folder(s) will be mounted into the containers
- The containers will have access to the shared folder(s) for reading and writing files
- The shared folder(s) will be used to store the Ansible playbooks and inventory files
- The shared folder(s) will be mounted at
/labs-scriptsin the containers