Setup Fedora Workstation Ansible

Overview

This post covers setting up personal a Fedora Workstation with Ansible, using a playbook with setup sections broken down into roles. Tags are used for testing and to further segragate tasks when modifying a configuration element.

  • I have been wanting to learn Ansible and there is nothing like doing the thing to help learn it.
  • I went through a couple of iterations of trying out Linux distros and took several Fedora Spins for a… spin. Automation was needed.

I thought I would share what I have to help out a fellow learner and to act as a reminder for me. The playbook is intended to be run locally on the workstation you wish to configure. It

Requirements
  • Fresh installation of Fedora Workstation.
  • Tested with Fedora 38 and Gnome 44.
    • Ansible
    • Git
1
2
sudo dnf install ansible git -y
git clone git@github.com:steve-rackham/ansible-workstation.git 
Tip: Adjust Variables:

Adjust the variable files for global variables and for each role.

  • Global: group_vars/all.yml
  • Role: /vars/vars.yml

Playbook

The playbook defines:

  • the host inventory.
    • Assumed localhost. #TODO: Add multiple hosts for automation across the home network.
  • root access for operations needing administrative privelege.
    • Use –ask-become-pass or -K for privilege escalation password.
  • the roles to be called.
    • System
    • User
    • App-Packages
    • App-Config
    • Desktop-Customisation

Tags may be used to target a role or particular task.


Examples:

First:

  • Update any var files and global vars as required.
  • From within the ansible-workstation directory:

Then run one of the following examples:

1
2
3
4
5
6
7
8
# Example: Run all roles and tasks on localhost:
ansible-playbook --inventory localhost site.yml -K

# Example: Run only themes tag
ansible-playbook --inventory localhost site.yml -K --tags theme

# Example: Run every but the themes tag
ansible-playbook --inventory localhost site.yml -K --skip-tags theme

The following roles are utilised and are intended to run in sequence.

Anything system or host related.

Tasks:

  • Set hostname.

User related settings and config.

Tasks:

  • Create directory structure.
  • Add SSH Keys.
  • Add git config.

Installation of repos, flatpaks, and app packages.

Tasks:

  • Add RPM and third party repos.
  • Add Flatpak repo.
  • Install:
    • Drivers.
    • Gnome Packages.
    • Shell Extensions.
    • Codecs.
    • User Packages.
    • User Flatpaks.
  • Remove unwanted packages.

Set application settings and config.

Tasks:

Set the desktop how we like it.

Tasks:

  • Install and apply:
    • Theme.
    • Icons.
    • Cursors.
    • Wallpaper.
  • Apply:
    • Common Gnome Settings.
      • FileChooser.
      • Numlock State.
    • Set Shell Extensions.
      • User Themes.
      • ArcMenu Settings.
      • Dash to Dock Settings.
      • Dash to Panel Settings.
      • Open Weather Settings.

Tags are heavily utilised throughout the playbook so you can target or test specific areas.

Show available tags:

1
ansible-playbook --inventory localhost site.yml --list-tags
1
2
3
# Result:
  play #1 (localhost): Fedora Workstation Configuration	TAGS: []
      TASK TAGS: [app-config, apps, cleanup, codecs, codium, cursors, customisation, dconf, debug, dnf, drivers, extensions, flatpaks, git, gnome, icons, remote-access, remove, repo, rpm, ssh, system, terminal, theme, wallpaper]

Items that would like to add to the playbook.

  • Add avatar for login prompt.
  • Set Power to Performance.
  • Add LibreWolf config.
  • Add Evolution config and backup/restore.
  • Check and mount data and gaming drives.

Summary

I have had a blast learning this far and am looking forward to further automation. Hope this helps you on your automation journey!

Cheers.