I chose Python because it’s what I was writing all day back in 2015. Which makes me realise pyinfra is almost 10!
Edit: I mostly write Go or YAML (k8s) these days but Python still makes an appearance from time to time (outside of pyinfra dev).
1,312 karma · joined January 11, 2012
Blog: pointlessramblings.com Email: nick@<username>.com
I chose Python because it’s what I was writing all day back in 2015. Which makes me realise pyinfra is almost 10!
Edit: I mostly write Go or YAML (k8s) these days but Python still makes an appearance from time to time (outside of pyinfra dev).
But there’s always edge cases and situations that doesn’t work which is why pyinfra supports both and they can combine any way you like.
Totally agree on templating which is why inventories have always been python code just as operations, giving maximum flexibility (with some complexity/type confusion drawbacks).
- state definitions, "ensure this apt package is installed" (apt.packages: https://docs.pyinfra.com/en/next/operations/apt.html#operati...) - stateless, "run these shell commands" (server.shell: https://docs.pyinfra.com/en/next/operations/server.html#oper...)
Most operations are state definitions and much preferred, the stateless ones exist to satisfy edge cases where either the state-ful version isn't implemented or simply isn't possible.
Any & all feedback much appreciated! It's basically just a very rough copy of the README at the moment.
Yes
> Is it meant for running one-off commands across the infrastructure, like Salt?
Also yes.
> It says it integrates with Terraform, so it's not a provisioning tool...
The TF integration is specifically to use TF as an inventory source - ie TF to create resources and pyinfra to then configure them.
> What does it do different (and presumably better) than other tools?
The homepage covers the highlights, I originally created pyinfra because debugging Ansible was complicated (no plain stderr as not "just" commands on the remote side) and slow, but things have evolved significantly since then.
> The Getting Started guide doesn't cover this. The FAQ doesn't cover this, and the Docs doesn't have an Introductory section to cover this.
Hugely appreciate this feedback, this is super helpful and something I will attempt to make clearer.
---
Quick attempt at a better explanation: You write Python code that defines operations (either state "this apt package should be installed" or stateless "run this command"), provide an inventory of targets (SSH, local machine) and pyinfra executes it.
Roughly sits where Ansible does for configuring servers, but also solves the case of "how do I run this command across my server fleet" (which I believe Ansible can also do).
I also hang out on the Matrix room: https://matrix.to/#/#pyinfra:matrix.org
Another thing: the GH repo points at currently in beta v3 and the docs for this are here: https://docs.pyinfra.com/en/next (highly recommend starting with v3, I just haven't had any time recently to wrap up the release, but it's stable).
For ansible/chef, etc the main reasons/benefits boil down to:
- instant feedback esp on errors, get the stdout/stderr of whatever command pyinfra was executing, there’s no agent or abstraction to hide it
- configure in python rather than yaml+jinja2 mess
- integrate with the whole python package ecosystem
- speed and small overhead as inventories scale
- ops are (mostly) declarative, but some (server.shell) will always execute the command given
- inventory is just that, basically a list of hosts to target plus associated data, docs page: https://docs.pyinfra.com/en/2.x/inventory-data.html
- absolutely for syncing files, check out the files.put and files.template operations (and the files ops in general): https://docs.pyinfra.com/en/2.x/operations/files.html
Twisted, however, is a different beast. Have spent s decent chunk of time working on Matrix synapse homeserver[2], written in twisted, and oh my it just sucks.
Most operations rely on various Linux/similar tools but the `server.shell` operation plus shell flag above should get you connecting and executing commands. Please do reach out if this doesn’t work for your setup!
I would love to test beyond that but haven’t had the opportunity sadly! Performance and scale is a headline feature so will always look to push this further.
Interested to hear more about this, might be something that can be added to paramiko (or on top of).
It’s been too long since I did perf testing but I still believe pyinfra Will significantly outperform ansible for the same tasks, you’ll have to try it ;) (also if perf is not good please raise an issue perf is absolutely a feature I wish to maintain)
> Every app that requests access to restricted scope Google user’s data and has the ability to access data from or through a third party server is required to go through a security assessment
An email client that only transmits data to/from Google's own IMAP/SMTP servers does not have the ability to access data through any third party server, and thus does not require the audit.
Source: https://support.google.com/cloud/answer/9110914?hl=en#zippy=...
> Ensure your app complies with the Google APIs Terms of Service, Google's API Services User Data Policy, and the Additional Requirements for Specific Scopes, which includes undergoing an annual security assessment if your app accesses restricted scope Google users data from or through a third-party server.
In the case of an email client data is transmitted directly from/to Google's own IMAP/SMTP servers and not a third party, and is thus exempt from the assessment.
By the looks of it Pegasus falls into this category and should not have any issues getting approved (still need the YT video and such but the Google team are surprisingly responsive and helpful in my experience).
So far the project hasn't cost anything directly financial, just my time which I intend to keep putting into the project because I enjoy it :). I use pyinfra day to day and it's great to see others getting use out of it!
There's a small but growing list of excellent contributors who really help drive things along and I'd love to grow that. A lot of time I put into the project recently and going onward is more around documentation and community to help with this.
I suppose another thing to note here is at it's core pyinfra is a pretty small codebase that doesn't require massive (time/money) effort to work on. The majority of code is in the operations themselves which I don't foresee expanding much (in favor of 3rd party packages).
Hope this provides some detail!