Cookbooks
yum
documentation
Dnf Module

Back to resource list

dnf_module

Provides interactions with the dnf module commands.

Actions

These map to dnf module subcommands, documented here (opens in a new tab) A basic summary for each is included below:

  • :switch_to - (Default) Enable a module stream and upgrade any packages to versions provided by the module
  • :enable - Enable a module stream without installing any packages
  • :disable - Disable a module stream without removing any packages
  • :install - Enable a module stream and install its packages
  • :remove - Disable a module stream and remove its packages
  • :reset - Unset module state and remove packages not in the default streams (this action is not idempotent)

Properties

NameTypeDefaultDescription
module_nameStringResource nameName of the module to install.
optionsString or ArrayAny additional options to pass to DNF
flush_cachetrue, falsetrueWhether to flush the Chef package cache after the module action

Flushing Chef's package cache is needed when switching to a module stream added during the Chef run, e.g. from a new repo.

Examples

Enable or update the Postgres module and related installed packages to PG 13:

# this is the default action
dnf_module 'postgres:13' do
  action :switch_to
end

Enable the Ruby 2.7 module (but do not install any of the packages):

dnf_module 'ruby:2.7' do
  action :enable
end

Enable and install packages from the PHP 7.4 module:

dnf_module 'php:7.4' do
  action :install
end