The Magic of Ansible


I have several physical machines (work laptop, personal laptop, personal desktop). I also like trying out new linux distros, so my personal machines usually have some kind of dual boot setup. But who wants to spend hours setting up a new machine with all of their favorite programs every time they swap operating systems? That’s where Ansible comes in — a tool I use to automate the mundane yet essential task of setting up a new computer. It’s all about getting from zero to hero with (for the most part) a single command.

When I face a fresh install of Ubuntu, Pop!_OS, or any of its cousins, I don’t sweat. I’ve got Ansible scripts ready to roll out my entire development environment. It’s like having my own development butler who knows exactly how I like my digital house.

The Command Center: My Configured Kitty Terminal

Kitty terminal, with its GPU acceleration, is my terminal emulator of choice. It’s sleek, it’s fast, and with tmux, it turns into a powerhouse allowing me to handle multiple sessions like a breeze. I’ve considered checking out alacritty as I hear good things about that too.

The Editor of Choice: Neovim

For code editing, I’ve got Neovim. No need to go into much detail here - but needless to say I’ve spent a good amount of time configuring it to my liking which you can read about here

Node.js and the Usual Suspects

Node.js, npm, and other JavaScript tooling is part of my tech stack. Along with Node, I automate the installation of various utilities that are part of my daily repertoire. Grep, curl, git, and all the other things that you wind up installing ad hoc all get installed automatically.

Dotfiles on Demand

Pulling down my dotfiles is the key piece of all of this. They’re the heart of my custom configurations, from the aliases in my .zshrc to the intricate setups in my .vimrc. I store them in a GitHub repo, and with Ansible, they’re pulled and placed exactly where they need to be. I use GNU Stow to automatically symlink everything from my dotfiles repo to the ~/.config folder, so I can always reset from a clean slate if needed.

Staying Updated

Updating is a breeze. When there’s a new version of something that I need, like an updated version of Neovim, I don’t have to go through the tedium of manual update processes. I just run my Ansible playbook again, and it takes care of fetching the latest versions.

The One-Liner to Rule Them All

So, how does it work? On a brand new machine, I have to clone my ansible git repo and run a script I wrote to install Ansible itself. Once Ansible is on the system, I run my Ansible playbook. This playbook is like a script for a stage play where each role—be it software, configurations, or scripts—is an actor. It systematically applies my desired state to the system, ensuring that every piece of software and every configuration is set up just the way I like it.

Why Ansible?

Some might wonder, why Ansible? Isn’t dealing with yaml annoying? Why yes, it is. However, there’s some perks that outway the pain. Ansible is idempotent, meaning I can run it multiple times without worrying about messing up the current state of the system. It also means that if I interrupt the playbook or if it fails at some point, I can run it again, and it will pick up right where it left off. It’s also a commonly used tool so there’s oftentimes existing tasks that I can copy from others to set up common tools like git, ssh, etc.

Bottom Line

Automation with Ansible is like giving your future self a gift. The hours saved mean more time to focus on the important things, like configuring neovim for the 100th time or trying out the latest linux distro.

With Ansible, I’ve made the setup of a new machine as easy as cloning a repo and running a command. It’s a seamless transition that lets me hit the ground running, no matter where I am or what Ubuntu-based distro I’m using. I’d love to have it be platform agnostic but right now most of my scripts are dependent on apt/apt-get. If you haven’t gotten on the automation bandwagon yet, take it from me—it’s worth the ticket. Even if you don’t hop around machines as much as I do, codifying your setup is like insurance if you happen to get a new machine.