News for hackers. Stuff that matters.
Re:Pyinfra: Automate Infrastructure Using Python by Fizzadar on Tuesday April 30, 2024 @12:52PM (#40213162)
Yes... and no. It depends on the operation (the docs explicitly state if an operation is _not_ idempotent "stateless operation"). Operations are either:

- 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.

Re:Pyinfra: Automate Infrastructure Using Python by tetha on Tuesday April 30, 2024 @01:26PM (#40213534)
Ah, so this is similar to the Terraform CDK approach?

In Terraform CDK, you use a language like python to compute the set of resources and such you want to have, and then hand that over to the terraform core, which does the usual terraform song and dance to make it happen.

This is actually interesting to me, because we struggle with even the simplest data transformations in ansible so much. Like, as soon as you start thinking about doing a simple list comprehension in python in jinja templating, lots and lots of pain starts. From there, we're really starting to think about templating the inventories in some way because it would be less painful.

Re:Pyinfra: Automate Infrastructure Using Python by Fizzadar on Tuesday April 30, 2024 @01:54PM (#40213910)
Interesting, not heard of CDK before! Kind of similar? As long as the language is Python I suppose! Would be possible to integrate with other languages too I guess, not something I’ve ever looked into though.

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).

Re:Pyinfra: Automate Infrastructure Using Python by F-Lexx on Tuesday April 30, 2024 @03:26PM (#40215174)
Relevant XKCD: https://xkcd.com/303/
Re:Pyinfra: Automate Infrastructure Using Python by 4m1rk on Thursday May 02, 2024 @01:45AM (#40233061)
CDK just generates AWS CloudFormation files (There is CDK for TF as well as said before, but is not the AWS official implementation). It's like having a few constructs to allow you generate a YAML or JSON file.