I want to register a variable with my java version. I can get that with:
java -version 2>&1 | head -1 | awk 'BEGIN { FS = "\"" } ; { print $2 }'
That gives me the result I want: 1.8.0_45
But I cannot make this happen in ansible :-( I'm going crazy with quotes and escapes. I've tried:
- name: Get java version
shell: >
java -version 2>&1 | head -1 | awk 'BEGIN { FS = "\"" } ; { print $2 }'
register: java_ver
and:
- name: Get java version
command: "{{ item }}"
with_items:
- java -version 2>&1 | head -1 | awk 'BEGIN { FS = "\"" } ; { print $2 }'
register: java_ver
as well as trying various combinations of quotes and escape characters. I just can't get the right recipe.