Skip to main content

yum

yum module

Manage packages with the yum package manager. This module can install, upgrade, or remove packages on Red Hat-based systems.

Examples

- name: Install a package
yum:
name: httpd
state: present

- name: Install multiple packages
yum:
name:
- httpd
- mysql-server
- php

- name: Update all packages
yum:
name: "*"
state: latest

- name: Remove a package
yum:
name: httpd
state: absent

- name: Install from specific repository
yum:
name: nginx
enablerepo: epel

- name: Update cache before operation
yum:
name: git
state: present
update_cache: true

- name: Remove unused dependencies
yum:
autoremove: true

Note: This module requires yum to be installed on the target system and is typically used on Red Hat, CentOS, and Fedora systems.

Module Capabilities

  • Has Revert: false
  • Provides Variables: None

Inputs

ParameterTypeDescriptionRequiredDefaultChoices
autoremoveboolRemove leaf packages that were installed as dependencies but are no longer needed.falsefalsetrue, false
disablerepoanyRepository names to disable for this operation. Can be a string, comma-separated string, or list.false
enablerepoanyRepository names to enable for this operation. Can be a string, comma-separated string, or list.false
excludeanyPackage names to exclude from the operation. Can be a string, comma-separated string, or list.false
nameanyName of the package(s) to operate on. Can be a string or list of strings. Use '*' to operate on all packages.false
statestringDesired package state.falsepresentpresent, installed, latest, absent, removed
update_cacheboolRun yum makecache before the operation.falsefalsetrue, false
update_onlyboolOnly update packages that are already installed, don't install new packages.falsefalsetrue, false

Outputs

FieldTypeDescription
packages[string]Packages operated on
statestringFinal state (installed, removed, updated)
versions[string]Versions installed/removed (if applicable)