Live data from Hacker News

PyInfra 3.8.0

github.com

61–70 of 110 posts

Re: PyInfra 3.8.0

#61
post #5

Has anyone used this and ansible and is able to give a short comparison with likes and dislikes?

I switched from Ansible to Pyinfra for my homelab, and continue to use Ansible at work. The biggest difference is that Pyinfra is simply Python code. It's incredibly easy to control the system in whatever manner you need to. You can probably do the same thing in Ansible, but it's never quite as obvious how to do it. This also means it's much more clear where and why things work the way they do in Pyinfra, where in An…

Just having "home/docker.py" instead of "collections/ansible_collections/home/dev/roles/docker/tasks/main.yml" is reason enough. Which one of the 300 main.yml files do I load when doing a quick open in any modern text editor?

Re: PyInfra 3.8.0

#62
post #2

Disclosure: PyInfra core contributor here. We just shipped 3.8.0. PyInfra is an agentless infrastructure automation tool. Same job description as Ansible, Salt, Chef. SSH into hosts, describe desired state, it diffs and converges. No agent, no central server, no daemon. The difference: your "playbook" is just Python. Not Python cosplaying as YAML. Not Jinja smuggled inside YAML inside a Helm chart inside a Kustomize…

Yeah, but I have Claude Code or Codex do this Ansible stuff and they do just fine with all this and then there's a gazillion of examples that they can lean on and once the patterns are established, it's pretty smooth. Opus 4.5 was when the big inflection was I was heavy into automation all summer. It was Opus 4.0. It was like pulling teeth. And then when 4.5 came out, it was just beautiful.

Yeah, you’re gonna eat your words when you do something that’s not “install this package” and “create this user”.

For anything dynamic and sufficiently complicated, ansible is horrible. Pyinfra is much better.

Re: PyInfra 3.8.0

#63
post #2

Disclosure: PyInfra core contributor here. We just shipped 3.8.0. PyInfra is an agentless infrastructure automation tool. Same job description as Ansible, Salt, Chef. SSH into hosts, describe desired state, it diffs and converges. No agent, no central server, no daemon. The difference: your "playbook" is just Python. Not Python cosplaying as YAML. Not Jinja smuggled inside YAML inside a Helm chart inside a Kustomize…

Thank you for this. I've implemented my own version of this a couple times over the previous 25 years. This is how my code always looked.

I've used Salt, CFEngine, Chef, Puppet, Make, Bash, and many hand-rolled iterations of this approach. I finally threw in the towel and forced myself to come to terms with Ansible and it's quirks because I needed the wider community support.

Now with AI tooling, I'm not so convinced the community modules moat is an actual moat. I'm going to very seriously consider porting all my Ansible code to this and see how it feels. I anticipate I'll be much happier after the change.

Do you have any plans to integrate with/build on other communities modules? i.e. even if it's not perfect, being able to call Ansible or Salt modules from PyInfra would be one way to fill the gap.

Re: PyInfra 3.8.0

#64
post #55

Earlier quoted context omitted.

The problem is that it is actually not just Python, branched with “normal if statements”: https://docs.pyinfra.com/en/3.x/deploy-process.html#checking...

You can write `if CHECK: do something`. There's nothing preventing that. I've been down this path, implemented my own version of PyInfra many times over the years. I've used Ansible and my own implementations in anger. The _if param is far far far from the worst offender and it's a natural addition, especially when you are laying out a bunch of unrelated checks into something that looks more like a table.

This! Been trying to find the best (least worst) solution to this since 2015 when I started pyinfra. Done ast parsing/hacking, done weird context managers instead, tried rewriting statements to context managers. _if is the latest, and I think least worst, option right now.

Basically a flaw of the entire model where you write code as if executing a single host which is then executed on many in parallel, forcing the two step diff and deploy that causes this.

Funny thing is since v3 this behavior (diff then execute) is even desired with the yes prompt like terraform.

Re: PyInfra 3.8.0

#65

Earlier quoted context omitted.

There is a PR open for llms.txt and llms-full.txt. We'll try to merge it soon! Disclosure: another contributor here.

It's amazing to see more contributors! TBH, I was worried a few years ago that there was basically just one (original) contributor. This now gives me added trust that I'm taking the right decision to lean heavily into it. I hope more people start using pyInfra. Thank You for your contribution and attention!

Indeed! (I am that original contributor :)), lots of work ongoing to address this, we now have a small maintainers group and are sharing out review and release loads.

Re: PyInfra 3.8.0

#66

Earlier quoted context omitted.

There is a PR open for llms.txt and llms-full.txt. We'll try to merge it soon! Disclosure: another contributor here.

It's amazing to see more contributors! TBH, I was worried a few years ago that there was basically just one (original) contributor. This now gives me added trust that I'm taking the right decision to lean heavily into it. I hope more people start using pyInfra. Thank You for your contribution and attention!

Thanks!

There are currently 3 active maintainers incl. the creator of pyinfra. But there are many more contributors incl. repeat contributors.

Re: PyInfra 3.8.0

#67
post #28

I've been using PyInfra for a while, albeit just for simple automation (Updating systems, checking certain stats) and I'm a big fan. Compared to Ansible, I found the docs, syntax and usage patterns much easier to get on with. Might just be a preference thing, but I always had trouble going through the Ansible docs. Ran into some bugs, like one machine that seems to cause errors and mess up the output on restart, alth…

Glad it clicked. The Ansible vs PyInfra docs gap isn't really preference, YAML plus Jinja plus a custom DSL is just more cognitive load than plain Python with type hints. Once you can grep the source and read it like normal code, going back feels rough. On the restart bug: if it resurfaces, an issue on GitHub with the OS, connector (ssh/local/docker), and raw output would help a lot. The 3.x line cleaned up a bunch a…

Really need to try PyInfra, the concept sounds nice.

You don't have to do crazy things with Ansible for that yaml DSL becoming the opposite of helpful. Things which would be quite straightforward to express in code become quite cumbersome, hard to understand and hard to debug. Also Jinja is often a horrible choice (you don't have in Ansible). Also Ansible excessively requires it in places where you want proper types and not just a string.

Re: PyInfra 3.8.0

#68
What I really want is something like either ansible or this that:

- Doesn't unnecessarily send code over the network.

- Has some sort of "execution optimizer".

Think for example a query planner/optimizer of a db. Or, as a good example, the query planner of the polars framework as opposed to how it works in pandas.

If I do a for loop and each loop iteration copies a file into the same dir, the optimizer should catch that and send over one compressed tar file.

Re: PyInfra 3.8.0

#70
post #51
post #41

Earlier quoted context omitted.

As a heads-up, your comments here were flagged. I think some people must have thought your (current) writing style rather LLM-ish.

It obviously was LLM assisted, but I think collectively we will have to get over our distaste for text that has some LLM’isms in spots as long as it isn’t obviously completely outsourced to a bot, unless we just want to shut down message boards completely.

[deleted]
Post reply on HN