Hello, I have recently been seeing a boom in people using ansible for automating setting up vps’s, services, …

Is it worth it to learn ansible to do also automate the way I setup everything, or is a bash script good enough ( I know some bash scripting but ansible seems like it could be more worth the time to learn )?

16 points

I think it is a great way to document what you have done too. Especially with larger setups this can be quite time-intensive.

Then add that you may want to dynamically reconfigure your systems to interact with each other and then Ansibles template-rendering comes in really handy.

Finally, it is standardized - so other peopke can work with it too (relevant in work context).

permalink
report
reply
2 points

This sounds amazing!

You have any good resources to recommend for learning ansible?

permalink
report
parent
reply
5 points

I recently began learning Ansible and this playlist was very helpful with learning.

permalink
report
parent
reply
2 points

Here is an alternative Piped link(s):

this playlist

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I’m open-source; check me out at GitHub.

permalink
report
parent
reply
4 points

Sorry, but I fear not. Ansible has a good getting started out there, but I think you’ll learn the most just using it.

Maybe a broad roadmap… Try to add systems. Test them via Ansible-Ping. Change some configs (add file, add line-in-file). Add handlers to react to changes by restarting services. Add host variables and customize behavior per host. Add templates…

permalink
report
parent
reply
3 points

Learn Linux TV has a good series as does Jeff Geerling both are free on YouTube.

I prefer the Learn Linux TV one as it goes through how to integrate git and different distros.

permalink
report
parent
reply
2 points

Yeah +1 for LLTV

permalink
report
parent
reply
2 points
*

I use it and I like it, but other people have their own favorites. The online docs are fine.

permalink
report
reply
15 points

Configuration management and build automation are definitely worth the time and effort of learning. It doesn’t have to be ansible, find which tool suits your needs.

permalink
report
reply
31 points

IMHO Ansible isn’t much different than a bash script… it has the advantage of being “declarative” (in quotes because it’s not actually declarative at all: it just has higher-level abstractions that aggregate common sysadmin CLI operations/patterns in “declarative-sounding” tasks), but it also has the disadvantage of becoming extremely convoluted the moment you need any custom logic whatsoever (yes, you can write a python extension, but you can do the same starting with a bash script too).

Also, you basically can’t use ansible unless your target system has python (technically you can, but in practice all the useful stuff needs python), meaning that if you use a distro that doesn’t come with python per default (eg. alpine) you’ll have to manually install it or write some sort of pythonless prelude to your ansible script that does that for you, and that if your target can’t run python (eg. openwrt on your very much resource-constrained wifi APs) ansible is out of the question (technically you can use it, but it’s much more complex than not using it).

My two cents about configuration management for the homelab:

  • whatever you use, make sure it’s something you re-read often: it will become complex and you will forget everything about it
  • keep in mind that you’ll have to re-test/update your scripts at least everytime your distro version changes (eg. if you upgrade from ubuntu 22.04 to 24.04) and ideally every time one of your configured services changes (because the format of their config files may in theory change too)
  • if you can cope with a rolling-style distro, take a look at nix instead of “traditional” configuration management: nixos configuration is declarative and (in theory) guarantees that you won’t ever need to recheck or update your config when updating (in reality, you’ll occasionally have to edit your config, but the OS will tell you so it’s not like you can unknowingly break stuff).

BTW, nixos is also not beginner-friendly in the least and all in all badly documented (documentation is extensive but unfriendly and somewhat disorganized)… good luck with that :)

permalink
report
reply
6 points

Fun fact: I actually run nixos on my main pc.

permalink
report
parent
reply
10 points

You will hate Ansible if you are coming from Nix. I went the other way and Nix is 1000x cleaner.

Being able to actually reverse changes is trivial in Nix, but can be a headache in Ansible. Not to mention the advantages of writing in an actual language and not yaml full of template hacks. I personally don’t see much future for tools like Ansible, there is considerable inertia working in its favor right now and it is absolutely true that it is widely used, but the future of configuration management is for sure more aligned with how Nix works.

permalink
report
parent
reply
3 points

I have been setting it up on my home, still not done but I can already see some benefits from it, e.g. I’m about to build a new server and migrate a lot of stuff to it, with ansible it will be very easy to just move some configs around and setup the server in no time at all. It also is encouraging me to keep a standard on how I do things which is great, and after setting up some initial things now adding new services is quite straightforward.

Overall I think there are a lot of positives about it, especially if you have multiple machines to manage. But even for a single one the fact that you can recreate everything from scratch in just one command is quite awesome considering the amount of times I’ve redone my server from 0 for different reasons over the past years.

permalink
report
reply

Selfhosted

!selfhosted@lemmy.world

Create post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

Community stats

  • 5.3K

    Monthly active users

  • 3.7K

    Posts

  • 81K

    Comments