You are reading an unmaintained version of the Ansible documentation. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See the latest Ansible documentation.
dnf - Manages packages with the dnf package manager¶
If yes, removes all "leaf" packages from the system that were originally installed as dependencies of user-installed packages but which are no longer required by any such package. Should be used alone or when state is absent
conf_file
no
The remote dnf configuration file to use for the transaction.
disable_gpg_check
no
no
yes
no
Whether to disable the GPG checking of signatures of packages being installed. Has an effect only if state is present or latest.
disablerepo
no
Repoid of repositories to disable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",".
enablerepo
no
Repoid of repositories to enable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",".
installroot
(added in 2.3)
no
/
Specifies an alternative installroot, relative to which all packages will be installed.
list
no
Various (non-idempotent) commands for usage with /usr/bin/ansible and not playbooks. See examples.
name
yes
Package name, or package specifier with version, like name-1.0. When using state=latest, this can be '*' which means run: dnf -y update. You can also pass a url or a local path to a rpm file.
state
no
present
present
latest
absent
Whether to install (present, latest), or remove (absent) a package.
-name:install the latest version of Apachednf:name:httpdstate:latest-name:remove the Apache packagednf:name:httpdstate:absent-name:install the latest version of Apache from the testing repodnf:name:httpdenablerepo:testingstate:present-name:upgrade all packagesdnf:name:"*"state:latest-name:install the nginx rpm from a remote repodnf:name:'http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm'state:present-name:install nginx rpm from a local filednf:name:/usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpmstate:present-name:install the 'Development tools' package groupdnf:name:'@Developmenttools'state:present-name:Autoremove unneeded packages installed as dependenciesdnf:autoremove:yes-name:Uninstall httpd but keep its dependenciesdnf:name:httpdstate:absentautoremove:no
This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
For more information about Red Hat’s this support of this module, please
refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>