rash
Declarative shell scripting using Rust native bindings inspired by Ansible
Getting Started & Documentation
For installation and usage, see our Documentation.
Why Rash
Manage your scripts in a declarative style.
If you:
- think that long bash scripts are difficult to maintain
- love Ansible syntax to setup your environments
Or use it for your local scripts!
Then keep on reading.
Here is Rash!
Declarative vs imperative
Imperative: entrypoint.sh:
#!/bin/bash
REQUIRED_PARAMS="
VAULT_URL
VAULT_ROLE_ID
VAULT_SECRET_ID
VAULT_SECRET_PATH
"
for ; do
&& &&
done
VAULT_TOKEN=
Declarative: entrypoint.rh
#!/bin/rash
- name: Verify input parameters
assert:
that:
- env.VAULT_URL is defined
- env.VAULT_ROLE_ID is defined
- env.VAULT_SECRET_ID is defined
- env.VAULT_SECRET_PATH is defined
- name: launch docker CMD
command:
cmd:
transfer_pid: yes
env:
APP1_API_KEY: "{{ lookup('vault', env.VAULT_SECRET_PATH ) }}"
Docopts
docopt implementation included:
- Easy to define interfaces for command-line app.
- Automatically generate a parser from doc.
Example:
#!/usr/bin/env -S rash --
#
# Copy files from source to dest dir
#
# Usage:
# copy.rh [options] <source>... <dest>
# copy.rh
#
# Options:
# -h --help show this help message and exit
# --mode MODE dest file permissions [default: 0644]
- copy:
src: "{{ item }}"
dest: "{{ dest }}/{{ item | split('/') | last }}"
mode: "{{ options.mode }}"
loop: "{{ source | default ([]) }}"
Lightness
All you need to run Rash is a Linux kernel!
You can use it in your favorite IoT chips running Linux or in containers from scratch!
Status
Stable API with few modules.