I'm having an issue with a version compare not working for me in Ansible. In this example, Ansible runs the debug task, but I'm expecting it to be skipped. I'm running version 2.10.7. What am I missing?
---
- hosts: hqdbepo1
gather_facts: true
become: false
tasks:
- name: check NuGet version
win_shell: (Get-PackageProvider -Name NuGet -Force | Select-Object Version | Format-Table -HideTableHeaders | Out-String).Trim()
register: nuget_version
changed_when: false
check_mode: false
- name: Ensure the required NuGet package provider version is installed
debug: var=nuget_version['stdout_lines'][0]
when: nuget_version['stdout_lines'][0] | string | replace('', '0.0.0.1') is version('2.8.5.0', '<')
The nuget_version['stdout_lines'][0] is "3.0.0.1"
Yep. Turns out I thought the comparison was if 3.0.0.1 < 2.8.5.0, but it's the other way around.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.