Automating DNF Updates with Ansible

Keeping Linux systems up to date is critical for security and stability. In enterprise environments or home labs, manually updating multiple servers can be tedious and error-prone. With Ansible, you can automate DNF package updates, ensure services are running as expected, and even safeguard containers using Proxmox snapshots.

This article walks through a robust workflow for managing updates and system state verification.

Complete Tutorial Series: Automating Updates & Snapshots with Ansible and Proxmox

Dive into this three-part series that shows you how to safely automate updates while keeping your Proxmox environment under control. Step by step, you’ll learn how to handle updates with Ansible, create snapshots before making changes, and keep an eye on your snapshot inventory with automated reports.

🔧 Automated Updates with Ansible

📸 Create Proxmox Snapshots before Updates

📊 Monitor and Report Proxmox Snapshots


Why Automate DNF Updates?

DNF (Dandified Yum) is the default package manager for RHEL-based distributions like AlmaLinux, CentOS, and RHEL 8/9. Regular updates:

  • Patch security vulnerabilities.
  • Ensure software compatibility.
  • Prevent system drift across multiple servers.

Manual updates often lead to:

  • Missed patches.
  • Service downtime.
  • Human errors in large deployments.

Ansible addresses these by providing a repeatable, automated, and auditable update process.

Core Features of the DNF Update Automation

Our automated workflow includes:

  1. Pre-update service gathering
    Capture currently running services before updating packages.
  2. Package update execution
    Update all packages to the latest versions, with optional dry-run mode.
  3. Optional system reboot
    Reboot if required and wait for the system to come back online before verification.
  4. DNF update history logging
    Record the last DNF transaction to allow troubleshooting or rollback planning.
  5. Post-update verification
    Compare services before and after the update and report differences.
  6. Email reporting
    Send an update summary, including changed services and package history.