Closed danielpoonwj closed 5 years ago
@danielpoonwj Can you document example usage in the README? There's already some sample YAML that you can append to.
@elliotweiser thanks for your feedback! i've made the requested changes
Great work @danielpoonwj! I'm really psyched to see this role getting more usage and that the feature list is growing. I'll merge and release this ASAP. Thanks for your contributions!
Thanks @elliotweiser! This role has been a great addition to our provisioning and deployment processes. I definitely hope to continue contributing as we use this more extensively moving forward
Purpose
One of the limitations of SDKMAN is that it requires an interactive shell to work. Or through manually sourcing the initialization script and setting various environment variables.
For example, this makes it difficult to work with a
systemd
service that uses Java. A common approach around this is to useupdate-alternatives
to manage linking Java installations to/usr/bin/java
. Under the hood, it is managing symlinks from/usr/bin/java
to various alternatives.Note that this does not directly interface with SDKMAN, but helps candidates installed via SDKMAN to be accessed more easily.
Approach
This PR uses the Ansible
alternatives
module to accomplish this. Multiple entries can be set within thesdkman_update_alternatives
list, defining for example:This allows access to the
java
andjavac
binaries in the default Java version via/usr/bin/java
and/usr/bin/javac
respectively. Note that they are referencing the same candidate but different names, asjava
andjavac
are installed via the SDKMANjava
candidate.Compatibility Caveats
update-alternatives
preinstalled. To use this,dpkg
has to be installed.alternatives
module is not supported on OSX.