saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.18k stars 5.48k forks source link

[FEATURE REQUEST] rhel8 dnf module .... #62146

Open w3bservice opened 2 years ago

w3bservice commented 2 years ago

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

welcome[bot] commented 2 years ago

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 saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

mattboston commented 2 years ago

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
RobinWlund commented 2 years ago

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

DaAwesomeP commented 1 year ago

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.

sampipe commented 1 year ago

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
dennixxNL commented 1 year ago

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