Hi,
I am hoping that someone can explain a difference in behaviour when using the API, where success is achieved when using Python 2 (2.7 tested) and a failure occurs when using Python 3 (3.6 and 3.8 tested).
The outcome of running the same code with the 2 versions of Python are as follows (ansible == latest, but occurs on 2.9, 2.10 etc):
Python 2.7
./py2/bin/python test.py; echo $? → 0
extract of full output
controller1 | SUCCESS => {
“msg”: “a0492524b4da454d992d9987481cacf2”
}
node1 | SUCCESS => {
“msg”: “a0492524b4da454d992d9987481cacf2”
}
Ignore the fact that the machine ID is identical, as that is purely due to instances running from the same base image.
Python 3.6
./py3/bin/python test.py; echo $? → 2
extract of full output
[WARNING]: Unhandled error in Python interpreter discovery for host node1: ‘>’ not supported between instances of ‘NoneType’ and ‘int’
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: ‘>’ not supported between instances of ‘NoneType’ and ‘int’
node1 | FAILED! => {
“msg”: “Unexpected failure during module execution.”,
“stdout”: “”
}
controller1 | SUCCESS => {
“msg”: “a0492524b4da454d992d9987481cacf2”
}
I have attached the steps to reproduce the issue.
It seems to relate to the connection plugin, whereby unless a local connection is used then running with Python 3 will error, whereas Python 2 will not.
Cheers,
Ceri
(attachments)
ansible-api-test.txt (2.51 KB)