DEV Community

Cover image for Automating my personal Ubuntu with Ansible
Bruno Noriller
Bruno Noriller

Posted on • Updated on • Originally published at linkedin.com

Automating my personal Ubuntu with Ansible

I have two disclaimers:

  • First, a shout out to Jay Lacroix of the Youtube channel LernLinuxTV. You should check it out and I will comment more on it below.
  • Second, I am/was(?) a “Windows guy”. WSL aside, this was my first experience with Linux.

TLDR: https://github.com/Noriller/my-ansible


The sad (not really) backstory

As time passes, we hoard digital stuff... we install new applications, start changing a lot of configurations, download a LOT of stuff, new updates... even a “new” OS (I’m referring to upgrading to Windows 11).

With this, the computer starts to slow down... you can try to fight it, you can delay as much as possible, but the day comes... for the dreaded formatting and reinstalling.

The day came for me, after more than 3 years...

But I didn’t want to blindly reinstall, I wanted insurance.

  • First, my laptop came with an HDD and later I installed an SSD, so I use a tool that clones my SSD to my HDD.
    • It’s something I do every now and then. Like before upgrading to Windows 11. If you have another drive, external or not, it’s something I recommend.
  • Second, I don’t really need Windows so much anymore.
    • I do have some Windows only applications, but it’s something I wouldn’t be using every day.
    • A little of a spoiler, but even if I find out that Ubuntu is not for me, I can still use that inside WSL2 (even the graphical applications!)

What is Ansible

I’m not an Ansible specialist, I’m not even a decent DevOps... I mean, I know the names of a lot of tools and what they do, but the HOW... that’s another history.

Anyway... Ansible!

Ansible is an IaC (infrastructure as code) tool. Basically, you use code to set up infrastructure. It’s usually used to set up servers and computers.

Ansible basically makes sure that whatever you want present will be present and whatever you don’t want present won’t.

Ansible vs Scripting

Why Ansible? Sure, you can use scripts, but Ansible makes it easier to manage what you want or not in your setup.

For each package and application, it makes sure it’s there and installs if it’s not present. Same for configurations, files, and a lot more.

Why use it at all?

In programming, we use things like Docker and virtual machines that are, ultimately, discardable. This means that you can just throw everything up and then get everything back up without batting an eye.

This is something we don’t use on our personal tools.

Imagine being able to have YOUR computer everywhere you go?

You can sync all your shortcuts, configurations, apps installed and apply them to any computer you use.

You can, even, have multiple repos with different configurations (or only one using some shenanigans to change stuff) that you can easily switch, it would be like using multiple users, but in a totally different way.


Edit 2022-04-23:

Want to know more about Ansible?

Try this primer:
https://spacelift.io/blog/ansible-tutorial
They manage to explain what exactly is Ansible in a way I can’t.


What I did

I already knew that it was possible to use scripts and backups of the dotfiles to quickly reinstall everything, but when I searched on how to do I found this awesome tutorial using Ansible:

https://www.youtube.com/watch?v=gIDywsGBqf4

Using a lot of that as a base and then a lot of googling Ansible stuff I fired up a VM (virtual machine) and used a lot (a LOT) of trial and error to make an initial setup that I was happy with.

And with that done, I finally actually installed and fired it up for real.

From there, actually using Ubuntu for the first time for real, I started seeing things I liked and things I was missing from Windows, then little by little I can change either on Ubuntu or directly in the Ansible repo and apply it.

The workflow

First, keep in mind that I’m still learning how to use Linux, so I’m probably missing on how to do a lot of things. (So, any tips are appreciated.)

Basically, I’m using dconf dump to check differences, every time I change something I check it against my last dump and then I update the Ansible files.

I also put a lot of the dotfiles and dotfolders under git, started committing the changes here and there, and will try to see what changes and what I can use to make the Ansible better.

WSL2

One cool thing is that it works on Linux, be it server, desktop, or even WSL, which means that I can use this on WSL, so even on Windows I can use everything I configure in Linux.

And if you’re using the last versions of WSL, you can use even the GUI applications.

And I know (although I still haven’t tried) that you can even use your Ubuntu desktop on Windows using XServer (or something like that).

So, as I said before, even if I end up saying that Ubuntu isn’t for me, I can still use Ansible to automate the installation on WSL, along with most of the applications I use, then on Windows, I just figure out how to make shortcuts for them and install the Windows only stuff.

What does this mean for you?

Well, if you’re a Linux noob like me, you can try it in a VM and you will see that I made something similarish to Windows.
Then, if you want to give it a try, it’s a nice start, and from there you can make your own repo with your own configurations.
As said in the youtube tutorial I gave the link above, his repo is a work of years that, probably won’t even work because that has a lot of files missing.
Meanwhile, mine is something that is aimed at a new user. The configurations are those that I’m using, but it will create the exact desktop I’m using!
Then, when you fork and replace with the configs you want, you’ll have something that will work for you.

Now, if you’re a Linux veteran, then you probably can use it to have an easier time backing up your configurations and speeding up a reinstall (or a sync between multiple computers).
It will take a lot of work, although only one time, to migrate all your configurations to Ansible, but after that is done...


The next steps

Now, I’ll be using Linux and seeing if it’s for me or not.

Another thing is that I’ll be updating the repo a LOT.
There are shortcuts to add, scripts to fix, and things to learn.

I also want to, someway, somehow, be able to save the configuration to all the apps I use.

Finally, I’ll leave almost everything there and try to make sure it will always work for a fresh install.

And for things that shouldn’t be public, when I figure out if and how I can “automate” I’ll try to make some kind of template for you to use.


TLDR (again): https://github.com/Noriller/my-ansible

Try it out and give me Linux tips. 😉


Cover Photo by Gabriel Heinzer on Unsplash

buy me a coffee

Top comments (0)