Reputation: 374
What would be the most appropriate way to execute arbitrary python code inside the target host ?
I saw the operations.python which use "the context of a deploy". The context seem to be an interface representing the host, but python code is running inside the master computer.
With the following snippet, it shows code is not executed on target, having working directory of the master :
from pyinfra.operations import python
import os
def callback(state, host):
print(os.getcwd())
print(os.getuid())
python.call(name="Python callback",
function=callback)
Should I put a script on the host and execute it, or there is a cleaner alternative ?
Upvotes: 2
Views: 708