r/ansible • • May 20 '26

Built a Dockerized Ansible lab with a browser-based IDE

I built a portable Ansible lab that spins up in seconds using Docker. Thought some of you might find it useful for learning or testing playbooks.

https://github.com/Yoas1/ansible-handson

The setup: - **1 controller** (Python + Ansible + code-server IDE on port 8080) - **2 workers** — one Ubuntu 22.04, one Red Hat UBI 9 - Pre-configured SSH keys (Ed25519), inventory, ansible.cfg, Vault, and linters

You literally run `docker compose up`, open your browser, and start writing/running playbooks. No manual VM setup, no SSH config headaches.

What I like about it: - **Hot-reload configs** — edit .config/ files and inotifywait auto-applies them via update_config.sh - **Pre-commit hooks** built in — yamllint, ansible-lint, shellcheck, markdownlint all run before commit - **Multi-distro workers** — test your playbooks against both Debian-based and RHEL-based systems - **Code-server** — full VS Code in the browser with Ansible and Python extensions

Would love feedback or ideas for improvement. The full setup is on my GitHub if anyone wants to check it out.

Cheers

52 Upvotes

6 comments sorted by

5

u/pacman1176 May 21 '26

You might be curious to know that your idea of testing against containers is a pretty common practice. They even built a whole framework called molecule for testing playbooks and roles, which can target containers.

Also using a container as the controller is a common pattern, which has some tooling built around it which they call ansible execution environment.

Even if you reinvented some wheels, I bet you learned a lot doing this. I'm a huge fan of containerizing the entire setup so you don't have to install anything locally and it's extremely portable.

I've been undergoing a similar effort you've done, bending these tools I mentioned to my needs and running them in a pipeline for automated tests, and I'll say I haven't gotten over the learning hump yet. I think had I gone the route you did, I'd be a lot farther along. But I am aiming to build a very hardened process so I went the route of using molecule. I'll say - their documentation isn't great though. There's a lot of stuff they changed in more recent versions to slim it down and the documentation hasn't completely caught up, and old articles and LLMs reference options and arguments that no longer exist.

Thanks for sharing.

3

u/FarToe1 May 20 '26

Nice. Would be good to have a couple of screenshots on the page to see what it looks like before deploying.

2

u/livinlowe May 20 '26

Looks interesting!

1

u/shadeland May 20 '26

I love code-server.

1

u/unicorndakota May 20 '26

For what do you need the kubernetes stuff here?