ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
815 stars 1.49k forks source link

alternatives module should be able to use "command" to set the alternative #5060

Open pglizniewicz opened 2 years ago

pglizniewicz commented 2 years ago

Summary

The alternatives module's behavior should match what the alternatives command does.

Given:

$ sudo alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.3.0.7-1.el9_0.x86_64/bin/java)
*+ 2           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.el9_0.x86_64/bin/java)

when I try to set an alternative for java to a specific command:

- name: configure default JDK
  become: true
  community.general.alternatives:
    name: java
    path: java-17-openjdk.x86_64

It will result in an error: Specified path java-17-openjdk.x86_64 does not exist

Running alternatives from the command line like sudo alternatives --set java java-17-openjdk.x86_64 works and sets the expected alternative

Issue Type

Feature Idea

Component Name

alternatives

Additional Information

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @mulby click here for bot help

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

kirk444 commented 1 year ago

I'd like to add my support for this issue. In the case of something like the rolling "java-latest-openjdk" package it's somewhat of a necessity:

# update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-4.0.1.el8.x86_64/jre/bin/java)
   2           java-latest-openjdk.x86_64 (/usr/lib/jvm/java-20-openjdk-20.0.1.0.9-8.rolling.el8.x86_64/bin/java)
whitehat237 commented 6 months ago

+1. I would like this functionality as well. Any status updates on this? I'd rather not resort to use of the command or shell module.