-
Notifications
You must be signed in to change notification settings - Fork 57
Only install Java 1.7 if java is not present or lower version #32
base: master
Are you sure you want to change the base?
Only install Java 1.7 if java is not present or lower version #32
Conversation
roles/common/tasks/main.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still an ansible noob here, but wouldn't this NOT install unzip and which if java version is already 1.7 and above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @ketan, that's correct. @boukeversteegh, can you extract the java installation to a separate task to ensure the other basic dependencies are still installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good one, i'm testing out a patch now, will post today or tomorrow
…a was already installed
|
||
- name: yum install Java 1.7 and some basic dependencies | ||
- name: Fetch Java version | ||
shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g' | grep '^.\..' -o || echo 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it is worth, grep version | awk '{print $3}'
is the same as awk '/version/ {print $3}'
. However, you don't need to combine awk, sed, and grep for this. You can simplify this to one grep to get the line, and one grep to extract a number from that line.
shell: java -version 2>&1 | grep version | grep -o '[0-9][0-9]*\.[0-9][0-9]*' || echo 0
Alternatively, if you're confident that the first line with a number has the number you want:
shell: java -version 2>&1 | grep -o -m1 '[0-9][0-9]*\.[0-9][0-9]*' || 0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, cool, thanks for those tips. i'm no longer actively using this playbook, so i can't test it, but if you are confident of course feel free to adapt and merge.
|
No description provided.