dnf
dnf 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
Parameter | Type | Description | Required | Default | Choices |
---|---|---|---|---|---|
autoremove | bool | Remove leaf packages that were installed as dependencies but are no longer needed. | false | false | true, false |
disablerepo | any | Repository names to disable for this operation. Can be a string, comma-separated string, or list. | false | ||
enablerepo | any | Repository names to enable for this operation. Can be a string, comma-separated string, or list. | false | ||
exclude | any | Package names to exclude from the operation. Can be a string, comma-separated string, or list. | false | ||
name | any | Name of the package(s) to operate on. Can be a string or list of strings. Use '*' to operate on all packages. | false | ||
state | string | Desired package state. | false | present | present, installed, latest, absent, removed |
update_cache | bool | Run yum makecache before the operation. | false | false | true, false |
update_only | bool | Only update packages that are already installed, don't install new packages. | false | false | true, false |
Outputs
Field | Type | Description |
---|---|---|
packages | [string] | Packages operated on |
state | string | Final state (installed, removed, updated) |
versions | [string] | Versions installed/removed (if applicable) |