Reputation: 737
Is there any way to create ansible playbook that finds out what version of python module is currently installed on destination host? I don't want to install specified version, I just want to know if it is present or not (example responses module installed: version 12.03
or module not installed
)
With pip
ansible module I found, that there is no state to ensure if something is installed, only possibilities is to install or remove
Upvotes: 5
Views: 8321
Reputation: 417
How about this for POSIX systems?
- name: check version of pytz
shell: pip show pytz | grep Version | cut -d ' ' -f 2
ignore_errors: true
changed_when: false
register: pytz_version
To just print the module version:
- debug: var=pytz_version.stdout
You can also use the version as a 'when' clause in other tasks:
- name: Do something requiring pytz 2012d
command: foo
when: pytz_version.stdout | search("2012d")
Upvotes: 3