In this article, we’ll describe the functionality and usage of the Ansible YUM module or ansible.builtin.yum or ansible.builtin.dnf, exploring how it simplifies package management tasks for administrators and DevOps engineers.

Understanding ansible.builtin.yum

ansible.builtin collection included default yum or dnf module that managed package operation on the managed host. The ansible.builtin.yum module servers as a connection between the playbook and the YUM package manager. which is the default package management utility for RPM-based Linux operating systems like CentOS, AlmaLinux, Rocky, Oracle Linux, etc. This module enabled users to perform a variety of package-related operations, including installation, removal, and updating across multiple systems.

ansible.builtin.dnf is for systems using DNF, and ansible.builtin.yum is for systems using YUM. It’s important to choose the appropriate module based on the package manager installed on your target systems.YUM was the default package manager in older versions of CentOS, Fedora, and RHEL, it has been largely replaced by DNF in newer versions.

I have explained How Ansible Navigator and the Ansible execution environment can install. Click here to read more.

Before working on the yum or dnf module, you can check the description or attributes through the following command and how to use this module in the example section.

ansible-navigator doc ansible.builtin.yum 
ansible-doc ansible.builtin.yum 

You can add the -s option will show attributes before the doc then it will show only attribute information.

Important Features and Functionality

Package Installation

This allows system administrators to install packages on remote-managed systems effortlessly. By defining in the playbook the desired package, users can ensure software installations across their infrastructure.

Package Removal

The administrator can remove the unwanted package by defining remove in the playbook. Ansible will handle the removal process efficiently.

Package Updating

Keeping systems up-to-date is crucial for security and stability. users can update packages through playbook defining.

Usage and Syntax for ansible.builtin.yum

The usage of ansible. builtin.yum ro ansible.builtin.dnf the module follows a simple and intuitive syntax within Ansible playbooks.

- name: Install package 
  hosts: host_pattern
      - name: Install httpd package
             name: package_name ( eg httpd )
             state: present

In this example, the playbook instructs Ansible to install the Apache web server package (httpd) on remote hosts designated as web servers.

The ansible.builtin.yum or ansible.builtin.dnf module empowers administrators and DevOps practitioners to streamline package management tasks within their infrastructure.

By Sachin G

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks! Sachin G Follow me on LinkedIn and x formerly twitter