Live data from Hacker News

Show HN: Welder – set up your Linux server with plain shell scripts

github.com

11–20 of 71 posts

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#13

I came from setup shell scripts (especially running in the postinstall step of debian-installer) to Ansible, and I think the big win with Ansible is at least the ideal of idempotency. That's a lot harder to achieve with plain shell scripts, unless you're pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).

I think this is much less of an advantage if you follow the pattern of "immutable servers", where, instead of mutating and updating servers directly, you just blow them away and provision new ones. The biggest benefit to systems like Ansible and Salt with that use case is the templating/config systems, which are much more flexible and powerful than what you can get with shell scripts (and which Welder, incidentally, provides).

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#14
post #9

Could you explain what this line of code does? ssh -t user@example.com "$(

Looks like a fancier version of ssh -t user@example.com "$(cat ./my-setup-script.sh)" I'll have to file this away myself!

Not fancier, just a bash-ism that may not work with some other shells.

[bash] https://www.gnu.org/software/bash/manual/html_node/Command-S...

[posix] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3...

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#15
post #9

Could you explain what this line of code does? ssh -t user@example.com "$(

it runs the local contents of ./my-setup-script.sh on the remote server in a way that escapes all the special characters so they don't do unexpected things.

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#16
post #9

Could you explain what this line of code does? ssh -t user@example.com "$(

It allows you to run a local shell script on the server via ssh, using bash command substitution - the "$(<" part. The -t option (force tty) executes the script in an interactive session - without it stuff like password prompts won't work (if I remember correctly).

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#17

I came from setup shell scripts (especially running in the postinstall step of debian-installer) to Ansible, and I think the big win with Ansible is at least the ideal of idempotency. That's a lot harder to achieve with plain shell scripts, unless you're pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).

Stupid question, but why are Ansible playbooks supposed to be "more idempotent" than plain shell scripts? Due to taking over a project I had to deep dive into it pretty quickly and to me it feels like shell in yaml syntax.

You might be on the same idempotency level with very disciplined shell scripts, but you won't have reporting out of the box. If I deploy something with ansible, I can see which changes were applied. This way, I can see whether I just changed something I didn't want to change. Other than that, yes, much discipline makes the difference. I know exactly what a core module does, but I have to read the entire shell script of "that colleague" to understand what it really does.

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#18

I came from setup shell scripts (especially running in the postinstall step of debian-installer) to Ansible, and I think the big win with Ansible is at least the ideal of idempotency. That's a lot harder to achieve with plain shell scripts, unless you're pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).

Stupid question, but why are Ansible playbooks supposed to be "more idempotent" than plain shell scripts? Due to taking over a project I had to deep dive into it pretty quickly and to me it feels like shell in yaml syntax.

As you get into more complicated setups, it certainly requires discipline, eg:

https://ryaneschinger.com/blog/ensuring-command-module-task-...

But as long as you're careful about coupling operations like lineinfile with checks for the line already being there and so on, you can achieve it (and Ansible certainly makes this much easier than shells scripts do).

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#19

I came from setup shell scripts (especially running in the postinstall step of debian-installer) to Ansible, and I think the big win with Ansible is at least the ideal of idempotency. That's a lot harder to achieve with plain shell scripts, unless you're pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).

Stupid question, but why are Ansible playbooks supposed to be "more idempotent" than plain shell scripts? Due to taking over a project I had to deep dive into it pretty quickly and to me it feels like shell in yaml syntax.

The answer is, they're simply not. Ansible is just as easy if not moreso to shoot yourself in the foot, only there's some smoke and mirrors (like their 'lineinfile' module) that make you think you're idempotent but actually just create race-conditions and reduce version control.

There are a few tricks that Ansible uses that are non-obvious uses of shell - For example, files should be replaced by copying the new version to the target directory, then unlinking the original file and linking in the new version in it's place, finally unlinking the temporary file. This functionality has been implemented in the 'install' utility in gnu and bsd coreutils since the 80s (though it's not in POSIX, so it's not exactly guaranteed; You'd be hard-pressed to find a machine outside of busybox docker images that does not support it)

Re: Show HN: Welder – set up your Linux server with plain shell scripts

#20

I came from setup shell scripts (especially running in the postinstall step of debian-installer) to Ansible, and I think the big win with Ansible is at least the ideal of idempotency. That's a lot harder to achieve with plain shell scripts, unless you're pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).

I think this is much less of an advantage if you follow the pattern of "immutable servers", where, instead of mutating and updating servers directly, you just blow them away and provision new ones. The biggest benefit to systems like Ansible and Salt with that use case is the templating/config systems, which are much more flexible and powerful than what you can get with shell scripts (and which Welder, incidentally,…

Sure, and set it up once and throw it away is always everyone's ideal, but there are going to be long-lived machines (like your database), and moreover, there are often times (such as during development) when it's really convenient to be able to iterate relatively quickly.

It's not realistic to perform a multi-minute deploy (or have to be resetting VMs to snapshots) just to try out tweaks in your non-idempotent setup script.

Post reply on HN