I’m attempting to compare version numbers of a app by extracting the current version from the output of a shell command and comparing it to the version to be deployed. However the result of the changed_when: evaluation is always true, regardless of the numbers I put in. I’ve confirmed the numbers that it’s evaluating through debug: msg tasks. Is there a way to make this work?
Here’s a simplified version:
- hosts: all
vars:
NEW_VERSION: 2
tasks:
- name: weblogic patch downgrade check
shell: "echo '2'"
register: current_version
changed_when: current_version.stdout > {{ NEW_VERSION }}
The actual task syntax i'm using
- name: weblogic patch downgrade check
shell: "cat /app/psoft/logs/wlversion |sed -n -e 's/^Patch \([0-9]\{8\}\).*/\1/p'"
register: old_patch_version
changed_when: old_patch_version.stdout > {{ WEBLOGIC_PATCH }}
In this example, both old_patch_version.stdout and {{ WEBLOGIC_PATCH }} are returning 20844228 but the task is registering as changed: true.
Thanks!