Running from within python? (no CLI) #893
Replies: 3 comments 6 replies
-
Hi @tjohnston-cd, There's an API that you can use to use Pyinfra programmatically, but it's not considered stable, and not in the official docs at the moment (you can find an example on older docs versions here). As I understand @Fizzadar is assessing whether this will be an official implementation (stable and supported) or an (non-supported) internal API. For the first case, there's still some work to be done, for the latter there's the eventual internal changes that may affect it. Regardless of how things evolve, I risk to say that you could easily do things programmatically if you are willing to tinker a bit with the specific formats, shouldn't be much of an issue. If the decision is to support Python API, I just reinforce I would be happy to contribute to a stable API. |
Beta Was this translation helpful? Give feedback.
-
This is important for building a system that is reproducable. |
Beta Was this translation helpful? Give feedback.
-
+1 on this, would be super super useful for projects at work as well as personal projects 🙂 Had been looking for a code-first Ansible alternative for a while (e.g. that can be configured and called programmatically all from within Python), so when I stumbled upon Pyinfra v0/1 a long time ago I had assumed Pyinfra's philosophy followed this idea and that is was seen as a core differentiator or maybe not? I was a bit confused going through the documentation in v2 today because I could not find any mention of a Python API and all the examples were using the CLI only. Adding it back to the docs would be great (with a comment about the API being unstable but that a stable API is planned) |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm writing a python-based application that wants to use pyinfra under the hood.
I would like to call pyinfra as a library, so everything is self-contained in the python side of my application.
Is there a recommended way to replace the
pyinfra inventory.py deploy.py
CLI step with something in my python code? Or do I need to subprocess out to the CLI in order to run things?Beta Was this translation helpful? Give feedback.
All reactions