det.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon Server des Unterhaltungsfernsehen Ehrenfeld zum dezentralen Diskurs.

Administered by:

Server stats:

1.8K
active users

#pyinfra

0 posts0 participants0 posts today

#CommunityHosting #Ops

A small group of us are working on community level hosting of 'self-hosted' FOSS tools (think #NextCloud and more) setup as a local service offering for local grassroots organisations. We're seeking advice/tips/guidance.

We're keen to do some orchastration but want to avoid the complexity of say Kubernetes.

As a start we were looking at Ansible with Docker Swarm but we're now exploring other alternatives.

Anyone have experience at this sort of hobbist just a bit bigger than #HomeLab Ops scale?

#Pyinfra is being considered as an Ansible, in the projects words "Think ansible but Python instead of YAML, and a lot faster." (pyinfra.com)

Anyone have experience at this homelab/small hosting level? Would love any tips/suggestions for tools/approaches.

One source of inspiration is the 12Factor app methodology: 12factor.net

Personally, as a rubyist I'm always keen to know what the ruby community is doing in this space also.

Haven't seen many others doing work at this scale, lets use the tag #CommunityHosting to keep connected :)

@digital_justice_society

cc: @jadehopepunk @ryan @gilbert @bounding_star @steph @moxvallix @organvoid @teq

pyinfra.compyinfrapyinfra turns Python code into shell commands and runs them on your servers
#Python#DevOps#ruby
Continued thread

In the #Hetzner Cloud API, you can refer to resources by their ID (an integer) or their name. Both are unique. The name is user-defined and designed to be human-readable, but needs to be identifier-like.

For example, you'd name a server "db01" or a volume "db-main" or an IP address "db01-v6".

However, in #pyinfra, "name" is a reserved word and I can't use it, but "id" is something else, too.

For now I've used "handle" instead of "name", but I wonder whether you have better suggestions.

Continued thread

Wait, neither #pyinfra nor #BundleWrap run actual Python code on the remote hosts, right? They're apparently both basically just fancy wrappers for running shell commands, mainly via SSH.

In contrast, #Ansible _does_ run Python on the remote side. Which means that Python is required to be installed, but also means that you can do more sophisticated stuff than parsing CLI tool output. 🤔

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

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.

I was skeptical of PyInfra at first, but I had a working system within minutes and was building out my own deploys (sort of like Ansible Playbooks), but without any weird Yaml syntax.

I've used cfengine, Puppet, Chef, and Ansible, and while I might still use an agent based system if I had thousands of hosts, so far PyInfra has been the easiest and most straightforward configuration management system I've used. It's as straightforward as Chef, but agentless like Ansible.

It's been absolute pleasure to use so far.