Puppet 5.5.22, dnfmodule reset

I've been trying to figure out how to convert

dnf module reset php
dnf module install php:remi-7.4

to a stanza in a puppet module for several hours without any success.

Has anyone figured out how to do that? The doco on the puppet website is somewhat lacking, shall we say.


Solution 1:

I believe that reset isn't implemented with dnf module yet, just enable and disable, but it can be used as a package manager directly.

From a quick test on a CentOS 8 docker image this worked for me:

  package { 'dnf-utils':
    ensure      =>  present,
  }
  package { 'redhat-rpm-config':
    ensure      =>  present,
  }
  package { 'epel-release':
    ensure      =>  present,
    provider    =>  rpm,
    source      =>  'https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm',
    require     =>  Package['redhat-rpm-config']
  }
  package { 'remi-release':
    ensure      =>  present,
    provider    =>  rpm,
    source      =>  'https://rpms.remirepo.net/enterprise/remi-release-8.rpm',
    require     =>  Package['epel-release']
  }
  exec { 'dnf-enable':
    path        =>  $path,
    command     =>  'dnf config-manager --enable remi remi-test remi-modular-test',
    require     =>  Package['remi-release']
    refreshonly =>  true,
  }
  exec { 'dnf-modules':
    path        =>  $path,
    command     =>  'dnf -y module reset php',
    require     =>  Exec['dnf-enable']
    refreshonly => true,
  }
  
  package { 'php':
    provider    => 'dnfmodule',
    ensure      =>  'remi-7.4',
  }

I think the repos could be refactored to yumrepo resources, but this is a good base to use dnf module with Puppet.