this post was submitted on 30 Apr 2024
82 points (97.7% liked)

Selfhosted

39435 readers
1 users here now

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!

founded 2 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 22 points 7 months ago (1 children)

Coming from what looks to me like a different perspective to many of the commenters here (Disclosure I am a professional platform engineer):

If you are already scripting your setups then yes you should absolutely learn/use Ansible. The key reasons are that it is robust, explicit, and repeatable- doesn't matter whether that's the same host multiple times or multiple hosts. I have lost count of the number of pet Bash scripts I have encountered in various shops, many of them created by quite talented people. They all had problems. Some typical ones:

Issue Example
Most people write bash scripts without dependency checks 'Of course everyone will have gnu coreutils installed, it's part of every Linux distro' - someone runs the script on a Mac
We need to pass this action out to a command-line tool, that's obvious Fails if command-line tool isn't available, no handling errors from tool if they aren't exactly what's expected
Of course people will realise that they need to run this from an environment prepared in this exact (undocumented) way Someone runs the script in a different environment
Of course people will be running this on x86_64/AMD64, all these third party binaries are available for that Someone runs it on ARM
Of course people will know what to do if the script fails midway through People try to re-run the script when it fails mid-way through and it's a mess

The thing about Ansible is that it can be modular (if you want) and you can use other people's code but fundamentally it runs one step at a time. You will know for each step:

  • Are dependencies met?
  • Did that step succeed or fail (in realtime!)?
  • (If it failed) what was the error?
  • (Assuming you have written sane Ansible) you can re-run your playbook at any time to get the 'same' result. No worries about being left in an indeterminate state
  • (To an extent) It is self-documenting
  • Host architecture doesn't really matter
  • Target architecture/OS is specified and clear