Score:1

DNF Enable/Disable in Puppet

zm flag

I'm trying to get PHP 7.4 installed on my RHEL 8 system with Puppet, but can't get the package declaration right to disable php and enable php:7.4 with dnf. The Puppet Package documentation doesn't describe well, and I wasn't able to learn anything from this post: Puppet 5.5.22, dnfmodule reset

Right now, Puppet installs 7.2, and then these commands are run manually to upgrade.

dnf module disable php
dnf module enable php:7.4
dnf upgrade php

How do I do this all with puppet?

Score:1
in flag

Puppet's resource package has the provider attribute, which accepts dnfmodule as a value. This way, you can enable and disable module streams easily:

  # Uninstall whatever eventual pre-enabled stream
  # Different title, and module name in "module" attribute,
  # only to avoid conflict with actual 'php' package
  package { 'php:module':
    ensure   => disabled,
    name     => 'php',
    provider => dnfmodule,      # Configs module, not package
  }
  package { 'php:7.4':          # Use resource title to choose stream
    ensure      => present,
    provider    => dnfmodule,
    enable_only => true,        # Don't install whole module
  }
  package {
    'php': ensure => present,   # From enabled 7.4 stream
  }

Confirm with:

dnf module list php
rpm -q php
Score:0
cn flag

You could see if there is a module on the Puppet Forge, but failing that you can use exec resources with the creates argument (if the commands run create a specific file). Failing that, use the exec resource but tack on a touch command to create your own marker to keep the resource idempotent.

E.G:

exec {
  cmd => 'dnf module disable php && touch /etc/.dnf-php-disabled`
  creates => '/etc/.dnf-php-disabled'
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.