Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 21, 2022 03:59 pm GMT

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 (Im 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 didnt 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.
    • Its something I do every now and then. Like before upgrading to Windows 11. If you have another drive, external or not, its something I recommend.
  • Second, I dont really need Windows so much anymore.
    • I do have some Windows only applications, but its something I wouldnt 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

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

Anyway... Ansible!

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

Ansible basically makes sure that whatever you want present will be present and whatever you dont want present wont.

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 its there and installs if its 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 dont 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.

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 Im still learning how to use Linux, so Im probably missing on how to do a lot of things. (So, any tips are appreciated.)

Basically, Im 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 youre using the last versions of WSL, you can use even the GUI applications.

And I know (although I still havent 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 isnt 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 youre 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, its 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 wont 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 Im using, but it will create the exact desktop Im using!
Then, when you fork and replace with the configs you want, youll have something that will work for you.

Now, if youre 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, Ill be using Linux and seeing if its for me or not.

Another thing is that Ill 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, Ill leave almost everything there and try to make sure it will always work for a fresh install.

And for things that shouldnt be public, when I figure out if and how I can automate Ill 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


Original Link: https://dev.to/noriller/automating-my-personal-ubuntu-with-ansible-25bh

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To