问题
The chef client already has java installed on it. How can I check which version of java is installed using chef. I know I can write a small ohai plugin to do the same but is there any other way to check which java version is installed on the client? The java installation is not an rpm installation though on some endpoints it might be an rpm installation.
回答1:
We already attempt to query it in Ohai for you: https://github.com/chef/ohai/blob/master/lib/ohai/plugins/java.rb
However this is complicated because you can have multiple Java installs in parallel as long as you set $JAVA_HOME
and whatnot for each application, and there is no overall standard for JVM file locations, so if you think you might have multiple versions or just one version but off $PATH
you'll need to use code similar to the Ohai plugin in your own recipe (or your own Ohai plugin if you wanted to get fancy).
来源:https://stackoverflow.com/questions/48618622/how-to-check-which-java-version-is-installed