Even well-written scripts will do! Just know - if you go with writing your own, you're doing something someone probably already did as a module.
With proficiency Ansible is like writing declarative pseudocode. Say what you want and a huge library of Python will 'make it so'.
Eventually you'll have a library of roles that don't care about the operating system, maybe even the provider.
A peer comment mentions docker-compose. That's fine, but I prefer Ansible -- the DSL can be made very similar with a role... and it's far more capable. Like preparing the runtime.
Why not something like docker-compose and put all of the config bits into a single repo?
That way you can clone the repo on a new server and simply rebuild the containers.
Sure, you can take that manually configured sshd and replace it with something managed by ansible _after_ the initial setup, but not before.
In a lot of cases, especially if you are gonna be moving between machines, rather than scaling horizontally, your machines don’t need to be reproducible. You can just restore a backup and tweak the new stuff (network configuration, etc). This gets rid of an entire class of complexity and lets you just do things once (rather than figuring something out and encoding into config management DSL).
If you actually need reproducibility, then it makes sense to go all the way. Something like NixOS provides stronger guarantees than Ansible. There is definitely a larger learning curve than Ansible though.
a link or a couple of words would be great -- might save hours.
For low load systems, just using rsync/Borg by itself may be enough. The advantage of Borg is incremental, deduplicated backups.
I personally use borgmatic (which is a wrapper over Borg, that is nicer to configure). It comes with a fairly decent starting config: https://torsion.org/borgmatic/docs/how-to/set-up-backups/
sudo rsync -aAXv --exclude-from=exclude-list.txt --delete --numeric-ids --rsync-path="sudo rsync" / user
(the exclude list is just /dev /proc /sys /tmp /run /mnt /media /lost+found).
At a certain point you start to wonder if saving the 50 bucks a month is even worth it....
Thanks for explaining this though - really appreciate it.
With so many servers Ansible script would ocassionally fail on some servers (weird bugs, network issues, ...). Since the operations weren't always atomic we couldn't just re-run the script. it required fixing things manually.
Thanks to this and emergency patches/fixes on individual servers, we ended up with slightly different setup on the servers. This made debugging and upgrading a nightmare. Can this bug happen on all the server or just this one because it has a different minor version of package 'x'?
We switched to NixOS. It had a steep learning curve for us, with lots of doubts if this was the right decision. Converting all the servers to NixOS was a huge 2-year task.
Having all the servers running same configuration that is commited to GitHub, fully reproducable and tested in CI, on top of automatic updates of the servers done with GitHub action, was worth all the troubles we had with learning NixOS.
This entire blog post could be a NixOS config.
The fact that it's not hermetic and perfectly reproducible is a major problem for a fleet, but for single user it's a benefit. It offers a graceful migration path from a snowflake server to a managed server, and still works even if you can't manage to do 100% of the config automatically.
I don’t think there is a VPS provider that doesn’t use it.
Shouldn't the hosting provider have pointed me to it from the start? So weird!
The problem is that you will set up your first VPS by spending hours installing packages and tweaking configs by hand. But eventually you will need to upgrade the OS, or switch to bigger hardware, or change VPS providers. And then it’ll be a nightmare to recreate all that snowflake config elsewhere without forgetting some detail.
The upside is that it’s cheap and fast, especially compared to anything “serverless” that chargers per request.