Using pyinfra
python.execute
How pyinfra Works
API Documentation
Elsewhere
The Python module allows you to execute Python code within the context of a deploy.
python.execute(callback)