Setup your Linux workstation with Ansible

Last update: 25 March 2023

In this article, we'll discuss a prevalent challenge faced by software engineers, which becomes apparent when we need to reinstall our workstations.

The crux of the issue lies in how to effortlessly and seamlessly replicate our workstation setup onto another machine. Essentially, as software engineers, we want to know how to transfer our complete setup, including tools, packages, libraries, development environments, editors, and configuration files to a new machine in just a few minutes.

The common approach: the dotfiles approach

Before I dive into my approach, let's see how most of the people do today.

The common way is to have a Github repo, usually called dotfiles, where you store the config files of the common tools you use, that you update a couple of times per year. And once you want to replicate your installation somewhere else, you clone your dotfile repo, and start copying each file individually, what a tedious task ! Without mentioning that most of the time it does not work straightforward as you usually forget to install some dependencies or probably the config file is not updated, 🥴 !

If you have been already in that situation, you're not alone. I have good news for you, there is a better way. So let me introduce my approach.

My approach

My approach tries to address two major challenges :

  1. I want an easy way to replicate my whole setup in just a couple of minutes.
  2. I want to be able to test new tools/setup easily without interfering with my machine, and also I want to be able to do that in couple of minutes.

Let's dig into the first challenge:

You may be tempted to create some sort of bash script to install your packages and copy different files, that would work in theory, but it's going to be hard to maintain, not easy to read, not easy to export to other platforms... That's where Ansible make its appearance 😎

In nutshell, Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.

So all what you need to do, is to describe in yaml files the state of your machine, and Ansible will make the necessary to have your machine setup as you describe it.

One of the most powerful features of Ansible that I want to emphasize is its ability to ensure Idempotence in tasks. This means that if you run a task multiple times, you will get the same output every time. This feature is particularly important in certain scenarios. For instance, imagine you have a bash script that needs to handle cases of command failures when the resources you want to create already exist or have been modified. For example, you may want to clone a repo, but if it already exists, you may want to pull the latest changes instead. With Ansible, you no longer have to worry about running these tasks multiple times, as your machine will always mirror exactly what you define in the YAML files.

Let's take an example.

- name: Install wezterm
      - wezterm
    state: latest
  become: yes
  tags: install

- name: Create config directory
    path: ~/.config/wezterm
    state: directory

- name: Copy wezterm conf
    src: config/wezterm/wezterm.lua
    dest: ~/.config/wezterm/wezterm.lua

I think you can guess easily without even knowing yaml or Ansible what those lines do. But let's explain what it is.

You can check here to know more about Ansible. It's really a great and easy tool to learn, you'll love it for sure.

Now that we figured out how to replicate our setup quite easily, let's see how can we test it.

One way to test our setup is to create a VM and run our setup inside it. It's quite easy and straightforward.

Let's see a demo with my setup, so you can visualize all the steps


Before we start, make sure the following tools are installed on your system:

  1. qemu
  2. just
  3. tigervnc

Once you have installed the tools, you can proceed with the following steps to create and configure an ArchLinux VM.

  1. Clone the workstation repository:
$ git clone
$ cd workstation
  1. Start the ArchLinux VM in the background:
$ just start-vm

Configure the VM with the following command:

$ just configure all

The configuration process may take a while to complete.

  1. Connect to the virtual machine using TigerVNC:
$ vncviewer :5900
  1. Login to the virtual machine using the following credentials:
login: pythops
password: pythops


The new approach introduced here offers the advantage of setting up a functional system that can be easily, rapidly, and consistently replicated on demand. Additionally this way is much easier to maintain than the traditional way.

Read more ...

Minikube setup

kubernetes the hard way part 2

kubernetes the hard way part 1