Skip to content

About

System Automation powered by Ansible™

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

System Automation powered by Ansible™

CI Job REUSE status

A set of Ansible playbooks to setup Linux machines.

site.yml is everything, in the order it has to run. It is made of two playbooks that can also be applied on their own:

  • playbooks/common.yml: software and setup which does not require a graphical environment

  • playbooks/desktop.yml: setup for desktop computers

common.yml starts with the repository set-up the rest depends on - the Extra Packages for Enterprise Linux repos on *EL-like systems, and removing snap on Debian and Ubuntu. Both are no-ops everywhere else.

Layout

site.yml, playbooks/

the plays, which are lists of roles and nothing else

roles/

all the logic, one role per thing being set up

vendor/roles/

third-party roles, see the licence section below

inventories/

the machines to apply this to: local is this machine, lima the test VMs

test/

container and VM test setups

scripts/

the wrappers documented below

Configuration

Every role carries its own defaults in roles/<role>/defaults/main.yml, which is where the package lists live. The few variables shared by more than one role, username above all, are in playbooks/group_vars/all/defaults.yml.

To change any of them, put the keys into playbooks/group_vars/all/local.yml. That file is gitignored and picked up automatically, so no extra flag is needed:

playbooks/group_vars/all/local.yml
username: alice
directories_paths:
  - "~/code"

Only the keys present in that file are overridden, the rest keep their defaults. Leaving the file out entirely is fine.

Setup

Everything below needs git, ansible, curl, bash and unzip installed:

Fedora

sudo dnf install -y git ansible curl bash unzip

*EL-like

sudo dnf install -y git ansible-core curl bash unzip

Ubuntu/Debian

sudo apt -y install git ansible curl bash unzip

openSUSE

sudo zypper --non-interactive install git ansible curl unzip bash

Arch Linux

sudo pacman --sync --refresh --noconfirm ansible curl bash unzip git

Get the sources and the collections the roles depend on
git clone https://github.com/fwilhe2/system-automation.git
cd system-automation
ansible-galaxy install -r requirements.yml
❗
The ansible-galaxy step is not optional. Several roles use modules from community.general, and the first one of them runs early in the common playbook.
Apply the playbooks
ansible-playbook --ask-become-pass site.yml
ansible-playbook --ask-become-pass playbooks/common.yml   # just the headless half

ansible.cfg names the inventory and the role paths, so both commands need no flags - but they have to be run from the root of the checkout, which is where ansible.cfg is found.

⚠️
Ubuntu 25.10 and later, including 26.04, default to sudo-rs instead of sudo. Older ansible-core releases don’t recognize the password prompt sudo-rs prints, so --ask-become-pass hangs or fails with a privilege escalation error even with the right password. This is fixed upstream, but the ansible-core version apt install ansible pulls on Ubuntu 26.04 may predate the fix. Install a current ansible-core with pipx install ansible-core (or pip install --user ansible-core) and use that instead of the distro package if you hit this.

scripts/run.sh wraps that, taking the playbook name without the .yml suffix and defaulting to everything:

./scripts/run.sh
./scripts/run.sh desktop

Roles are tagged with their own name, so a single one can be applied on its own:

ansible-playbook --ask-become-pass playbooks/desktop.yml --tags firefox

Opting out, and carrying on past a failure

Anything after the playbook name goes to ansible-playbook, so any tag below can be skipped (several at once, comma-separated):

./scripts/run.sh --skip-tags docker,firefox       # opt out of single roles
./scripts/run.sh --skip-tags upstream             # only what the distro repositories carry

Ansible stops at the first failing task. If a single role is broken - typically an upstream one whose download site is down - --keep-going applies the roles one at a time instead, asks for the password once, and lists the failed ones at the end together with the --skip-tags that leaves them out next time:

./scripts/run.sh --keep-going
./scripts/run.sh --keep-going desktop --skip-tags upstream

That is slower, as every role gathers facts again, so it is meant for the run after a failure rather than as the default.

Tag Selects

upstream

roles that download from outside the distribution’s repositories (GitHub, vendor repositories, …​)

epel

EPEL repository on EL

snapd_purge

removal of snap

basic

basic packages

dotfiles

oh-my-zsh and the dotfiles repository

bin

the fwilhe2/bin repository

directories

directories in the home directory

docker

Docker

development

compilers, toolchains, development packages

rust

rustup

uv

uv

virtualization

virtualization tools and lima

gcl

gcl

gh

GitHub CLI

telemetry

telemetry opt-outs

codium

VSCodium and its extensions

vscodium

VSCodium extensions only

firefox

Firefox Nightly

tor_browser

Tor Browser

rpm_fusion

RPM Fusion on Fedora

desktop

desktop packages

libreoffice

LibreOffice settings

grind

grind

spellcheck

spellchecking dictionaries

Kickstart (experimental)

If you don’t mind the curl | bash thing, scripts/bootstrap.sh does the download, the ansible-galaxy step and the common playbook in one go:

curl https://raw.githubusercontent.com/fwilhe2/system-automation/main/scripts/bootstrap.sh | bash

Testing

Containerfile

A Containerfile exists per package manager, and all of them are built and run by the CI workflow. They apply common.yml and desktop.yml, each one twice to check idempotence (test/container/run-test.py), and then assert properties of the resulting system (test/container/assertions.py).

scripts/container-test.sh builds and runs one of them. The CI workflow calls the same script, so a green run here is the run CI makes. It takes distro[:version], where the version defaults to the first one listed in its --help, and it uses podman when available and docker otherwise:

./scripts/container-test.sh                     # fedora:latest, the full test suite
./scripts/container-test.sh debian              # debian:testing
./scripts/container-test.sh debian:unstable
./scripts/container-test.sh fedora:rawhide bash # ... with a shell instead of the test runner
./scripts/container-test.sh --help              # the distros and versions on offer

Inside an interactive container, python3 test/container/run-playbook.py <name> applies a single playbook without the assertions.

Every Containerfile takes the image to build on as its VERSION build argument, so building one by hand is:

docker build --build-arg=VERSION=debian:testing -t system-automation-test --file test/container/Containerfile.dpkg .
docker run --tty system-automation-test

The containers escalate privileges against test/container/inventory.yml, which carries the throwaway root password the images are built with, using the method named in each image’s ANSIBLE_BECOME_METHOD.

📎
Containerfile.archlinux applies common.yml directly instead of running run-test.py, so the Arch job checks that the playbook succeeds but not the assertions.
📎
When running an image with podman by hand, add --env SYSTEMD_OFFLINE=1, which is what container-test.sh does. None of the images run systemd, and ansible’s systemd module only notices that by itself under docker; under podman the docker role fails with "Service is in unknown state".

Lima

Lima is a tool written in go for running virtual machines. test/lima/ holds vm definitions for testing this repo:

# boot both fedora and debian
limactl start --yes test/lima/fedora.yaml
limactl start --yes test/lima/debian.yaml

# run the common playbook on both vms
ansible-playbook --inventory inventories/lima/hosts.yml playbooks/common.yml

# inspect the vms if needed
limactl shell fedora
limactl shell debian

# remove the vms when you're done
limactl delete -f fedora debian

The vm definitions pin the image location and its digest, so they go stale when a new release is published. test/lima/update-fedora-image.py refreshes those fields in test/lima/fedora.yaml.

The CI with Lima VM workflow runs the same thing on GitHub Actions, but only when triggered manually via workflow_dispatch.

License

Copyright © 2016-2026 Florian Wilhelm

Free use of this software is granted under the terms of the MIT License.

This project ships the following 3rd party software. The copies below have been modified, so they do not match their upstream projects:

ansible-role-codium (vendor/roles/greenleader.codium)

Copyright © Sion Fandrick under the MIT License

ansible-role-vscode (vendor/roles/iesplin.vscode)

Copyright © iesplin under the MIT License

ansible-role-visual-studio-code-extensions (roles/vscodium/library/codium_extensions.py)

Copyright © John Freeman GantSign Ltd. Company No. 06109112 (registered in England) under the MIT License

Ansible collection - gotmax23.epel (vendor/roles/gotmax23.epel*, roles/epel)

Copyright © 2022 Maxwell G (@gotmax23) under the MIT License

lima - linux virtual machines (test/lima/*.yaml)

Based on examples by Akihiro Suda and the lima contributors under the Apache-2.0 license

Ansible Role: snapd (vendor/roles/bodsch.ansible-snapd)

Copyright © Bodo Schulz under the BSD-2-Clause License

About

System Automation powered by Ansible™

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages