TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

158 点作者 pchm将近 8 年前

22 条评论

StanAngeloff将近 8 年前
I used to bootstrap a lot of VMs in development using shell scripts [1]. At a certain point Bash scripts become unmanageable. Ansible, Chef, Puppet have stricter syntax, battle-tested modules, large communities, proper multi-OS support, etc. Investing time to learn any of those tools certainly pays off in the long run.<p>Bash is great for a quick setup or a one-off instance. However it requires discipline for anything more. You are also dealing with the underlying OS yourself (e.g., Nginx is packaged and configured differently in Ubuntu, Debian, Cent OS &amp; Arch; networking is configured differently in Ubuntu depending on whether systemd is installed, etc.).<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;StanAngeloff&#x2F;vagrant-shell-scripts" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;StanAngeloff&#x2F;vagrant-shell-scripts</a>
评论 #14525576 未加载
dugmartin将近 8 年前
Here is a declarative bash DSL I ran across a few months ago:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mattly&#x2F;bork" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mattly&#x2F;bork</a><p>and here is an example from their README:<p><pre><code> ok brew # presence and updatedness of Homebrew ok brew git # presence and updatedness of Homebrew git package ok directory $HOME&#x2F;code # presence of the ~&#x2F;code directory ok github $HOME&#x2F;code&#x2F;dotfiles mattly&#x2F;dotfiles # presence, drift of git repository in ~&#x2F;code&#x2F;dotfiles cd $HOME for file in $HOME&#x2F;code&#x2F;dotfiles&#x2F;configs&#x2F;* do # for each file in ~&#x2F;code&#x2F;dotfiles&#x2F;configs, ok symlink &quot;.$(basename $file)&quot; $file # presense of a symlink to file in ~ with a leading dot done</code></pre>
edgan将近 8 年前
This is just plain a bad idea. Bash is the worst possible language. Yes, it can do it, but the syntax is awful. The problem of single quotes in double quotes in escaped double quotes.<p>I replaced a home grown, written by someone else, bash configuration management tool with Salt. The difference was huge.<p>Configuration management tools give you built-in logging, state checking, return codes, template libraries, and access to very mature models to access things like the AWS api.<p>I realize people don&#x27;t like the steep learning curve, but there is a reason for it.
atmosx将近 8 年前
Honestly, I find ansible quite simple and straight forward. You don&#x27;t have to use third party playbooks and using &#x27;autoenv&#x27; I achieved a very straight forward, simple, dynamic setup.
评论 #14524461 未加载
bjpbakker将近 8 年前
Author claims all 90% of the time all they need is a single shell script. Then shows an example directory structure that mostly reminds me of Ansible.<p>How is Welder different from Ansible, except bash vs python?
评论 #14523471 未加载
评论 #14523490 未加载
mikepurvis将近 8 年前
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.<p>That&#x27;s a lot harder to achieve with plain shell scripts, unless you&#x27;re pretty disciplined about only performing mutations to your system that are themselves idempotent (like a package install).
评论 #14524472 未加载
评论 #14522994 未加载
评论 #14523015 未加载
评论 #14522968 未加载
CyberShadow将近 8 年前
I created something similar for Arch Linux:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;CyberShadow&#x2F;aconfmgr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CyberShadow&#x2F;aconfmgr</a><p>It has a few crucial differences from typical configuration managers, though, as it allows transcribing the system state back into your configuration.
oneplane将近 8 年前
Basically, this is SaltStack&#x27;s salt-ssh re-implemented using bash instead of python... That too is just YML + Templates + Bash + SSH, with the exception that you can use Python too and the templates are JINJA.
callumjones将近 8 年前
If you don&#x27;t like all the directories that Ansible playbooks require you can use the simple style of a single YAML file that describes the actions to take. Check out <a href="https:&#x2F;&#x2F;serversforhackers.com&#x2F;an-ansible-tutorial" rel="nofollow">https:&#x2F;&#x2F;serversforhackers.com&#x2F;an-ansible-tutorial</a>, the first introduction walks you through setting up just 2 files.
mariocesar将近 8 年前
I did something Similar, but fully based in shell scripts with no dependencies -&gt; <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;mariocesar&#x2F;8e674ec40dad6b94114d2a44d9151e23" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;mariocesar&#x2F;8e674ec40dad6b94114d2a44d...</a><p>I completely agree with OP when Ansible is overkill for must cases, and even slower than a plain smart shell script.<p>For my solution, simple create a bash function:<p><pre><code> function play () local remote=${2} local script=${1} local directory=$(dirname ${script}) tar cpf - ${directory}&#x2F; | ssh -t ${remote} &quot; tar xpf - -C &#x2F;tmp &amp;&amp; cd &#x2F;tmp&#x2F;${dirname} &amp;&amp; bash &#x2F;tmp&#x2F;${script} &amp;&amp; rm -rf &#x2F;tmp&#x2F;${dirname} &quot; } </code></pre> and later just call it like.<p><pre><code> play provision&#x2F;bootstrap.sh ubuntu@10.0.0.1 </code></pre> Where provision is a directory, and bootstrap.sh is the main shell script.
joelcollinsdc将近 8 年前
Reminds me of <a href="https:&#x2F;&#x2F;github.com&#x2F;brandonhilkert&#x2F;fucking_shell_scripts&#x2F;blob&#x2F;master&#x2F;README.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brandonhilkert&#x2F;fucking_shell_scripts&#x2F;blob...</a>
ausjke将近 8 年前
I was really excited until I saw &quot;Welder requires rsync, ruby and liquid&quot; --- why do I need Ruby and all its dependencies here?<p>I tried <a href="https:&#x2F;&#x2F;github.com&#x2F;myplaceonline&#x2F;posixcube" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;myplaceonline&#x2F;posixcube</a> and it has zero dependencies , just bash itself, and it is nice.
cat199将近 8 年前
On the subject of non-approved sysadmin&#x2F;devops tools,<p>I wrote a little &#x27;tarball compiler&#x27; framework in mostly PMake some time ago to &quot;DevOps&quot; like it&#x27;s 19[89]9 ... basically it will build per-host file overlay trees, rdist them out to target hosts, and then optionally run user defined start&#x2F;stop&#x2F;restart hook scripts when needed.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ixcat&#x2F;admmk&#x2F;blob&#x2F;master&#x2F;doc&#x2F;admmk.rst" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ixcat&#x2F;admmk&#x2F;blob&#x2F;master&#x2F;doc&#x2F;admmk.rst</a><p>unfortunately, though it will do per-host targets, I didn&#x27;t get around to per-service targets.. should be feasable however.<p>Definitely a bit hairy, but hey, thats what quasi-functional symbolic makefile programming is all about my friends..<p>ps: if you think this is bad, try rewriting it in gnumake if that&#x27;s even possible.. PMake! Woo!
nwmcsween将近 8 年前
cdist was pretty much the same, you should see why they made the decisions they made
nodesocket将近 8 年前
There is really not much you can&#x27;t do using HashiCorp&#x27;s Packer[1] and Terraform[2].<p>Packer can generate base images and roles based on shell scripts and transferring files. Terraform manages the creation of infrastructure on clouds and can bootstrap instances with shell scripts as well.<p>[1] - <a href="https:&#x2F;&#x2F;terraform.io" rel="nofollow">https:&#x2F;&#x2F;terraform.io</a> [2] - <a href="https:&#x2F;&#x2F;packer.io" rel="nofollow">https:&#x2F;&#x2F;packer.io</a>
jazoom将近 8 年前
Sup also works well<p><a href="https:&#x2F;&#x2F;github.com&#x2F;pressly&#x2F;sup" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pressly&#x2F;sup</a>
snissn将近 8 年前
Could you explain what this line of code does?<p><pre><code> ssh -t user@example.com &quot;$(&lt; .&#x2F;my-setup-script.sh)&quot;</code></pre>
评论 #14523954 未加载
评论 #14522995 未加载
评论 #14523075 未加载
评论 #14523855 未加载
评论 #14523063 未加载
benbristow将近 8 年前
I was about to make the point about Ansible but I guess you&#x27;ve already made it in the README.
评论 #14522753 未加载
schizoidboy将近 8 年前
Similar tool: <a href="https:&#x2F;&#x2F;github.com&#x2F;myplaceonline&#x2F;posixcube" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;myplaceonline&#x2F;posixcube</a>
yakshaving_jgt将近 8 年前
Similar: <a href="https:&#x2F;&#x2F;github.com&#x2F;kenn&#x2F;sunzi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kenn&#x2F;sunzi</a>
ajmarsh将近 8 年前
Hm I&#x27;ve always just used pssh for this type of administration. I guess this saves a step not having to pscp.pssh the script onto the nodes.
nikolay将近 8 年前
Yet another Ruby-based solution?!
评论 #14524251 未加载