pch/welder
์๊ฐ
๐จโ๐ญ์ผ๋ฐ ์ ธ ์คํฌ๋ฆฝํธ๋ก Linux ์๋ฒ ์ค์
๊ฐ๋ฐ ๋๊ตฌWhat you can do
- set up your server with a single command (welder run <playbook> <server>)
- run a set of organized reusable shell scripts
- use simple template syntax ({{ VAR_NAME }}) to substitute config variables
์ธก์ ๋ ์คํ ์ฆ๊ฐ
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
์๋ก ๊ฒน์น๋ ๊ธฐ๊ฐ์ ์์ฆ๊ฐ๋์ด๋ฉฐ ์ผ๋ณ ํฉ๊ณ๊ฐ ์๋๋๋ค. ์ธก์ ๊ฐ์ด ์์ผ๋ฉด ๋น์ ๋ก๋๋ค. ์คํ๋ ๊ด์ฌ๋๋ฅผ ๋ํ๋ด๋ฉฐ ํ์ง์ ๋ณด์ฅํ์ง ์์ต๋๋ค.
README.md
Original๐จโ๐ญ Welder
Welder allows you to set up a Linux server with plain shell scripts.
I wrote it out of frustration with Ansible. Ansible is an amazing and powerful tool, but for my needs it's just too much. 90% of the time all I need is to be able to run a shell script on the server, without extra dependencies.
In most basic terms, that's what welder does.
But there's some more.
โ ๏ธ NOTE: if you're looking for the previous version of welder, you'll find it here.
Features
- set up your server with a single command (
welder run <playbook> <server>) - run a set of organized reusable shell scripts
- use simple template syntax (
{{ VAR_NAME }}) to substitute config variables
Directory structure
An example directory structure:
โโโ playbook.conf
โโโ config.conf
โโโ firewall
โ โโโ files
โ โ โโโ rules.v4
โ โโโ firewall.sh
โโโ nginx
โ โโโ nginx.sh
โโโ system
โ โโโ files
โ โ โโโ 10periodic
โ โ โโโ 50unattended-upgrades
โ โ โโโ ssh_key
โ โโโ system.sh
โโโ website
โโโ files
โ โโโ site.conf.template
โโโ website.sh
Playbook
Playbook is just a list of modules to execute. Example:
# playbook.conf
system
firewall
nginx
website
Config
Config file:
SITE_DOMAIN = "example.com"
SITE_DIR = "/var/www"
You can reference config variables in your scripts like this:
#!/bin/sh
set -xeu
. ./config.conf
echo $SITE_DOMAIN
Templates
Welder offers simple sed-based templates that interpolate variables in double brackets
with values defined in config.
# website/files/nginx-site.conf.template
server {
listen 80;
server_name {{ SITE_DOMAIN }};
root {{ SITE_DIR }}/current/public;
}
Usage
Run the playbook with the following command:
welder run playbook.conf [email protected]
How it works
Welder goes through the modules defined in playbook.conf, copies them to a
cache directory, compiles config files and templates, rsyncs the directory to
the server. Then it runs the setup script that invokes all *.sh files
within the playbook (all scripts will be called with sudo).
Example setup script
# nginx/nginx.sh
# NOTE: sudo isn't necessary because the whole script will be
# invoked as `sudo nginx/nginx.sh`
set -xeu # 'u' will give you warnings on unbound config variables
add-apt-repository -y ppa:nginx/stable
sapt-get update && apt-get install -y nginx
service nginx start
cp files/nginx.conf /etc/nginx/nginx.conf
# Disable default site
if [ -f /etc/nginx/sites-enabled/default ]; then
rm /etc/nginx/sites-enabled/default
fi
service nginx restart
Installation
The only dependency required by welder is rsync (which should be
pre-installed on your system in most cases).
Check out welder into
~/.welder(or whatever location you prefer):$ git clone https://github.com/pch/welder.git ~/.welderAdd
~/.welder/binto your$PATHfor access to theweldercommand-line utility.$ echo 'export PATH="$PATH:$HOME/.welder/bin"' >> ~/.bash_profileUbuntu Desktop note: Modify your
~/.bashrcinstead of~/.bash_profile.Zsh note: Modify your
~/.zshrcfile instead of~/.bash_profile.Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if welder was set up:
$ which welder /Users/my-user/Code/welder/bin/welder
Caveats
Since welder allows you to run anything on the server, you should use it
with caution. It won't protect you from screw-ups, like
rm -rf "/$undefined_variable".
Use at your own risk.
Alternatives
There's an alternative version of welder (the classic version), re-implemented in Python by @thomas-mc-work.
๊ด๋ จ ํ๋ก์ ํธ ์ดํด๋ณด๊ธฐ
๋ถ๋ฌ์ค๋ ์คโฆ