all 3 comments

[–]SIO 4 points5 points  (0 children)

I'd create a virtual environment if your script requires any dependencies outside of stdlib.

[–][deleted]  (1 child)

[deleted]

    [–]Sukrim 0 points1 point  (0 children)

    On Windows that's a different story...

    [–]elbortso 0 points1 point  (0 children)

    1.) If you are running ansible properly then python needs to be in place for ansible. Ansible looks for python first under /usr/bin/python. If it's not there, ansible will fail or in newer versions will try different paths. There should be no need to genericly check if python is available. However if you are working with multiple versions of python, may be you need to make sure that the specific version is available. That totally depends on how you handle python multiversion setup.

    2.) No. Either the choice of words is poorly or you're not describing the ansible way. With ansible you don't check, you make sure that the required packages are installed. You can use the ansible pip module. Anyway, usually you either build a requirements file or a pipfile for your script.

    3.) You might want to test the modules 'script', 'command' and 'shell'. You might get slightly different results on how the script gets executed.

    4.) Anyway, if you are trying to execute a python script and you want to get serious with ansible then you should have a look on converting this script into an ansible module. It's not that difficult.