Setting Up Ubuntu Desktop Using Ansible: Part 1

Jul 14, 2022, by Rovshan Mirza

I've been using Ubuntu Desktop VM as my casual web development environment for past couple of years now and I've gone through a few Ubuntu upgrades which sometimes made me anxious that it will break something I wouldn't be able to fix right away.

I could install a new version each time instead, but it's time-consuming to replicate my current setup manually. I was lazy to create a "bash" script for that, always delaying doing that. I'm also a Linux newbie who is scared of making 100% switch from Windows :).

Now, I love automating stuff, as any lazy tech guy or girl would, so I got really excited when I learned about Ansible. I watched some Youtube videos and read a few articles to see if I could use it for above purpose. And yes, it was totally possible and I want to show you how. Actually, Ansible is pretty flexible, but I don't think most people use it the way I do to provision a Linux desktop.

Mind you, there is still a lot of manual work you need to do before and after running Ansible playbooks (tasks), but I think you can automate it too, if you have free time and desire. I will post updates in the future when/if I find out how to do that, of course.

I hope you are already familiar with Ansible. If not, then I recommend watching Using Ansible to automate your Laptop and Desktop configs! Youtube video by Jay LaCroix. He shows how to use ansible-pull with Github repository, but we are not going to use them to accomplish the same.

In this part of the guide, we will prepare Ubuntu VM before we run Ansible playbooks (tasks). So, here is the first batch of steps.

  1. Download Ubuntu Desktop ISO
  2. Create VirtualBox VM
  3. Optional: Increase VRAM. I don't recommended doing this anymore as it slowed down my host OS the next day. It was working fine in the beginning.
  4. Install Ubuntu VM
  5. Install VirtualBox Guest Additions
  6. Update Ubuntu
  7. Install Ansible
  8. Take A Snapshot

1. Download Ubuntu Desktop ISO

Go to https://ubuntu.com/download/desktop and download Ubuntu 22.04 LTS.

2. Create VirtualBox VM

Create Virtualbox VM with below settings.

  • General:
    • Advanced:
      • Shared Clipboard: Bidirectional
      • Drag'n'Drop: Bidirectional
  • System:
    • Motherboard:
      • Base Memory: 4096MB
      • Processor: 2
  • Storage: 50GB fixed size
  • Display:
    • Screen:
      • Video Memory: 128 MB
  • Network:
    • Attached to: Bridged Adapter
    • Name: Intel Gigabit Network Connection
  • Shared Folders:
    • Add auto-mount shared folder from you host OS. My host OS is Windows 10 and I created a shared folder where I'm going to keep my Ansible playbooks. We will use this folder later in the next part.

3. Optional: Increase VM's VRAM

We selected maximum VRAM allowed in GUI earlier to be 128MB, but there is a way to increase it upto 256MB.

Remember, guest VRAM is using host RAM, not host GPU memory. So, you may not see any performance increase in your VM.

  1. Open CMD or PowerShell in Windows.
  2. Run below command from inside C:\Program Files\Oracle\VirtualBox\. Update the VM machine name accordingly.
    VBoxManage modifyvm "Ubuntu" --vram 256

4. Install Ubuntu VM

Install Ubuntu on VM using downloaded ISO. I chose walle as username during installation. You can choose your own.

5. Install VirtualBox Guest Additions

  1. Mount Virtualbox Guest Additions from Devices > Insert Guest Additions CD Image.
  2. Navigate to mounted VBox disk folder in Terminal.
cd /media/walle/VBox_GAs_6.1.34
  1. Run Virtualbox Guest Additions. Enter your password when prompted.
sudo ./VBoxLinuxAdditions.run
  1. Add user to vboxsf group.
sudo adduser walle vboxsf
  1. Unmount Virtualbox Guest Additions from Devices > Optical Drives.
  2. Reboot VM.

6. Update Ubuntu

If you didn't download updates during installation, this might take a while.

  1. Update Ubuntu.
sudo apt update && sudo apt upgrade -y
  1. Remove installed packages not used anymore.
sudo apt autoremove
  1. Reboot VM.

7. Install Ansible

Finally, install Ansible.

sudo apt install ansible

8. Take A Snapshot

This will be your temporary backup in case Ansible fails or you want to go back to initial state for some reason.

  1. Shutdown VM.
  2. Open your Virtualbox Manager and take a snapshot of VM.

Finally, Part 2 is ready now! Click on the link and start using Ansible to provision our Ubuntu Desktop for web development.