I am trying to apply a salt.states.alternatives
to set my default java to java 11. However, I need to put in the full path for the openjdk, which includes the version number that changes every time there is a version change (meaning I have to update salt state frequently):
set-java-11:
alternatives.set:
- name: java
- path: /usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64/bin/java
If I do alternatives --config java
, I can see that the path is tied to a command and a selection number.
There are 3 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-1.el7_9.x86_64/jre/bin/java)
2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64/bin/java)
So my question is: Is there a way in which I can set the salt state to use selection 2 without referencing the full path (such as referencing the selection number or the command)