salt icon indicating copy to clipboard operation
salt copied to clipboard

[FEATURE REQUEST] rhel8 dnf module ....

Open w3bservice opened this issue 3 years ago • 3 comments

i am currently creating an sls and desperately searching how to map "dnf module list...." or "dnf module enable/disable ..." in salt. the enable/disable feature is in CentOS/Alma Linux/Rocky Linux and Oracle respectively since rhel 8. with cmd.run it works. is there another more elegant way besides using a native command?

current salt-version 3004.1 Rocky Linux 8.6

w3bservice avatar Jun 09 '22 14:06 w3bservice

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

welcome[bot] avatar Jun 09 '22 14:06 welcome[bot]

I need to solve the same issue. Currently I'm doing this, but would be nice to have a salty method.

httpd-enable-module-mod_auth_openidc:
  cmd.run:
    - name: /bin/dnf module enable mod_auth_openidc

mattboston avatar Aug 30 '22 15:08 mattboston

Also curius about this feature for saltstack yumpkg module and state module.

RobinWlund avatar Sep 16 '22 11:09 RobinWlund

Has anyone found a clean way to check if a module is already enabled? Something that could be used with onlyif or unless? A not great solution requires some grep regex magic from dnf module list --enabled -q.

DaAwesomeP avatar Mar 04 '23 19:03 DaAwesomeP

This is what I do to get the latest available nginx installed being that the default module in RHEL8 is old.... shows the unless/onlyif.

disable_php_module:
  cmd.run:
    - name: dnf module disable php
    - onlyif: dnf module list --enabled | grep php

enable_nginx_1_20_module:
  cmd.run:
    - name: dnf module enable nginx:1.20
    - unless: dnf module list --enabled | grep nginx | grep 1.20

required_packages:
  pkg.installed:
    - pkgs:
      - nginx

sampipe avatar May 18 '23 19:05 sampipe

Great solution, although I agree this should be a Salt-native solution. I'd like to suggest a small change in your onlyif and unless statements, which eliminates the use of pipes and grep:

disable_php_module:
  cmd.run:
    - name: dnf module -y disable php
    - onlyif: dnf module list --enabled php

enable_nginx_1_20_module:
  cmd.run:
    - name: dnf module -y enable nginx:1.20
    - unless: dnf module list --enabled nginx:1.20

required_packages:
  pkg.installed:
    - pkgs:
      - nginx

dennixxNL avatar Sep 26 '23 09:09 dennixxNL