You are not logged in.

#1 2020-05-30 17:00:01

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 74
Website

awwan - Configuration management software

Hi Archers,

I build a tools to execute script in local or remote server using SSH, which can works as provisioning tools for your own private server.

Background

Do you have a collection of shell scripts to manage one more similar server? Do you ever want to execute only part of your script? Are you get tired with learning others syntax and tools for provisioning your own server, while you need is a handful of shell script?

If yes, awwan is the right tools for you.

The idea is simple: shell script like syntax, a SSH like configuration for hostname (e.g. ~/.ssh/config), and dynamic key=value configuration using INI file format.

Example

To give you the taste of the idea, I will show you an example using the working directory $WORKDIR.

Let say that we have the working remote server named "myserver" at IP address "1.2.3.4" using username "arch" on port "2222".

In the $WORKDIR, create directory ".ssh" and file "config",

$ mkdir .ssh
$ cat > .ssh/config <<EOF
Host myserver
    Hostname 1.2.3.4
    User arch
    Port 2222
    IdentityFile .ssh/myserver
EOF

still in the $WORKDIR, create  the environment file "awwan.env"

$ cat > awwan.env <<EOF
[all]
user = arch
host = myserver

[whitelist "ip"]
alpha = 1.2.3.4/32
beta  = 2.3.4.5/32
EOF

Inside the $WORKDIR we create the directory that match with our server name and a script file "test.aww",

$ mkdir -p myserver
$ cat > myserver/test.aww <<EOF
echo {{.Val "all::host"}}`
#put: {{.ScriptDir}}/test /tmp/
cat /tmp/test
EOF

and a template file "test",

$ cat > myserver/test <<EOF
Hi {{.Val "all::user"}}!
EOF

When executed from start to end like this,

$ awwan play myserver/test.aww 1 -

it will print the following output to terminal,

>>> arch@1.2.3.4:2222: 1: echo myserver

myserver
test                                                  100%    9     0.4KB/s   00:00
>>> arch@1.2.3.4:2222: 3: cat /tmp/test

Hi arch!

That's it.

If you interested and want to try it, the AUR package is in https://aur.archlinux.org/packages/awwan-git/ .

For more information, see the README on the project page is at https://sr.ht/~shulhan/awwan .

It has been used for deploying and managing postfix, dovecot, haproxy, and my personal server and services at kilabit.info.

Also it has been used to deploy and manage GCP and Kubernetes using combination of `gcloud` and `kubectl`.

Happy provisioning!

Offline

#2 2020-07-05 13:33:46

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 74
Website

Re: awwan - Configuration management software

Release awwan 0.2.0 (2020.07.05)

===  New features

*  environment: export the SSH key, user, host, and port

By knowing this values, user can use it to invoke other SSH related
command, for example to copy file using `scp`

  scp -i {{.SSHKey}} src {{.SSHUser}}@{{.SSHHost}}:{{.SSHPort}}/dst

*  all: add magic command "#require:"

Magic word `#require:` will ensure that the next statement will always
executed when its skipped with start number.
For example, given following script with line number

  1: #require:
  2: echo a
  3: echo b
  4: #require:
  5: echo c
```

executing `awwan local script.aww 3`, will always execute line
number 2 `echo a`, but not line number 5 (because its before line start 3).

===  Bug fixes

*  command: change the owner of file when doing #get!

In case the owner of file is not active user and it does not have
read permission, the "#get!" command will fail when copying command
from remote to local.

*  command: fix magic copy and get command on templates

===  Enhancements

*  command: merge sequences of spaces on command into single space

*  command: check for single, double, or back quote on command

Previously, if command contains quote like,

    echo "a b"

the script will run it as ["echo", `"a`, `b"`] which is not what we
will expected and may cause some command failed to run.

This changes fix the parsing of command string by detecting possible
quote.

Offline

Board footer

Powered by FluxBB