Skip to content

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

Closed
@pglizniewicz

Description

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

  • I agree to follow the Ansible Code of Conduct

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature requestmodulemodulepluginsplugin (any type)system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions