mstdn.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A general-purpose Mastodon server with a 500 character limit. All languages are welcome.

Administered by:

Server stats:

16K
active users

#pyinfra

0 posts0 participants0 posts today

Eine Frage an die PyInfra-Admins hier im fediverse. Ich hab mich in den letzten Tagen mit diesem Tool beschäftigt und so einige deploy-scripte geschrieben. Nun komme ich an Punkte, wo ich nicht sicher bin, ob das, was ich gerade mache, so im Sinne des Erfinders ist.

Ich möchte ein paar Server (6 - 10) per pyinfra einrichten. Dabei werden einige Server komplette Webserver mit PHP, PHP-FPM, diversen WebApps (Nextcloud, CMS, WIKI, etc.) und einige bekommen nur einen VPN-Server. Das ist so ganz grob mein Ziel.

Ich bin so weit, dass PyInra mir den kompletten Server aufsetzt. Von der statischen IP, ein paar Anpassungen an der .bashrc, den SSH-Port ändert, Apache, LetsEncrypt, fail2ban, php, php-fpm (beides für verschiedene php-versionen) usw. alles installiert. Toll!

Jetzt bin ich garde dabei, ein Deploy-Script zu schreiben, das mir die Umgebung für eine WebApp einrichtet: vhost.conf für die Domain erstellen und konfigurieren, User, Gruppe, HomeDirs, LogDirs usw. erstellen, LetsEncrypt-Zertifikate holen, usw.

Danach sollen dann all die WebApps (also zum Beispiel nextcloud) per deploy-script installiert werden.

Das sieht alles schon ziemlich gut aus und ich kann mir vorstellen, wie das alles zusammen spielen wird. Aber es ist noch ein weiter Weg.

Mein Problem ist gerade, dass mein Inventory-Script allein nur für einen Host in Kürze bei etwa 200 Zeilen an Host-Data Umfang hat. Ich habe die Befürchtung, dass ich bei dem Umfang an Parametern den Überblick verliere und Fehler mache. Wenn man nur mit dem simplen Dictonary von Python arbeitet, kann man leicht einen Fehler machen, wenn man einen Key angibt und sich dabei vertippt. Es gibt ja keine Fehlerkorrektur oder ein Check, dass der Name des Keys richtig geschrieben wurde. Oder man vergisst einen Eintrag im Dictonary - also in der Beschreibung des Hostes - vorzunehmen. Und dann fliegt hinterher alles auseinander. Ich bin nun dabei, eigene Klasse für die Hosts, Apps und so weiter zu erstellen und dafür zu sorgen, dass dort alles korrekt ist. Aber das ist eine riesige Menge an Arbeit, die mal nicht in 2 Tagen erledigt scheint.

Ist das sinnvoll? Ist das der richtige Weg? Wie handhabt ihr das?


@robertmx @linux #pyinfra #linux #administration #it

Wer hat Ahnung von PyInfra? Ich arbeite mich da gerade rein und bin eigentlich ziemlich angetan. Abgesehen davon, dass ich ständig bei meinen Suchanfragen im Netz auf Tipps zu alten Versionen stoße, die dann meist nicht funktioniert 🙁

Ich würde zum Beispiel aktuell gern wissen, wie ich die Existenz einer Datei auf dem Server prüfen kann, wenn die Datei nur mit root-Rechten zu sehen ist. Ein "_sudo=True" kann man nicht überall einbauen. Auch das globale "_sudo=True" scheint nicht zu helfen.

Also irgendwas der Art:

myfile = host.get_fact(
File,
"/root/.bashrc",
)


Hat da einer eine Idee?

#pyinfra #Python @linux

Continued thread

* The selfhosting docs on deltachat are somewhat rudimentary. Theres a github repo and some #pyinfra scripts, but compared to #synapse and #xmpp, the docs are less sophisticated

In conclusion I would recommend #xmpp for a closed organizational messaging due to LDAP integration and "enterprise" features and delta chat for nontechnical communication (if you can live without video / audio).

3/3

Replied in thread

@sumanthvepa For everything you want to do, I'm pretty sure you'll have to do a lot of custom coding regardless of how you do it, but you could check out #pyinfra which is like a more lightweight version of Ansible. Or I should say, it's a lighter-weight tool that tries to do the same thing Ansible does (basically, scripting but optimized for configuring systems). I don't know if it will actually make your job easier, I'm just suggesting it's worth a quick look to see.

Replied to nebucatnetzer

@nebucatnetzer I'm working on it, for my personal infrastructure. It is wayyyy more pleasant (and efficient) to be writing code in an actual programming language instead of in YAML, but the tradeoff is losing access to Ansible's huge library of tasks and roles. So you wind up having to implement more things yourself in pyinfra. Personally, I think it's well worth it so I will continue to plug away with pyinfra, but I can see how someone who's working on a large body of infrastructure and has limited time might consider it not viable.

Replied in thread

@Zer0Rank @nebucatnetzer as for if I would do it again? Definitely! I wrote so many ansible modules in my day. But a lot qas due to the only tool that made the least trade offs for me. Ansible now over a decade old and for all its capabilities, a lot of the cuts are all still there with it.

#pyinfra feels fresh. You can also get very far depending on how well you know the language. Ansible is more of learn how to code in yaml and jinja REALLY well. 🫠

Replied in thread

@RyuKurisu @mmeier

The strengths of #K8S (autoscaling, rebalancing, self-healing) were not terribly relevant to my homelab.

The disadvantages (high resource usage and complexity) started bothering me. I had some machines idling at 20% CPU just for all the management processes.

I went on to orchestrate the #homelab with #ansible / #pyinfra and used plain old #docker containers. That massively reduced complexity, load, traffic and WTF moments (spent days hunting bugs in the flannel CNI).

PyInfra demonstrates a powerful point. With Ansible if you want to feed information to Ansible, you must do through so Yaml. Yaml is fine, but PyInfra simply lets you feed information directly to it without an intermediary file format.

Why do we complicate our lives with these intermediate formats when they're often unnecessary? Wouldn't pure programming be better for the user?

I'm looking at you, OpenTofu.