1

I would like to ensure Java is installed and the oldest acceptable version is 11. How can I achieve that in ansible?

I have tried

- name: Fetch Java version
  shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
  register: java_version

- assert:
    that:
      - java_version.stdout | version_compare('11', '>=')

Which does not work anymore because of the discontinued syntax in the assert.

1 Answer 1

2

Apparently you can just replace | with is in the assert:

- name: Fetch Java version
  shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
  register: java_version

- assert:
    that:
      - java_version.stdout is version_compare('11', '>=')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .