Checking python version through ansible results into error
Solution 1:
Just as a note:
Python version is already gathered by the setup_module and can be accessed by ansible_python_version
ansible -m setup localhost | grep ansible_python_version "ansible_python_version": "3.6.1",
Solution 2:
I see no error here. Command has been executed successfully (rc=0
).
Python's -v
switch is supposed to write version number to stderr. From source:
fprintf(stderr, "Python %s\n", PY_VERSION);
If (for some specific reason) you need to see it in stdout instead, use descriptor redirection:
- shell: python --version 2>&1