This is (or will be) a collection of scripts that make my everyday workflow easier.
Currently it's only for me, this is a public repository so I can download the scripts easily on any machine without logging in into GitHub.
Maybe someday I will provide a more thorough README
with detailed usage information of this repo.
- All scripts should use
#!/bin/bash
. Avoiding bashisms will bring a lot of overhead and difficuly into scripting and I'm not planning using those scripts in environments that don't havebash
. - No hardcoding. Also try using as few environment variables as possible (e.g. from
$HOME/.env
). - Avoid storing sensitive data in plain text files. If a secret is used by any of the scripts, this secret should be kept in
pass
and the user should be propted for a password. - If a script is calling another script or tool, the user should be informed about this, e.g. a message like
Executing command: command --long-option=something arg1
should be displayed.
- Provide examples/templates for common parts of an
sh
script like:- argument parsing (short options, long options and positional arguments)
- printing which checks
--quiet
,--verbose
or--very-verbose
flags, think of them like log-levels - display quick usage docs with
--help
- display
script-name [options] args
one-liner description when the script exits with an error - pretty-printing setup with colors
- Gather the above in a sample script that can be cloned and used as a template + oneliner
curl
command which downloads the template
Build a set of wrapper scripts around common kubectl
+ awscli
commands that are context/profile aware:
- The profiles/contexts should be parsed from
~/.kube/config
or~/.aws/config
- These scripts should be chainable (by calling each other) to achieve something more complex, e.g:
- Getting a secret from a k8s secret-store in a
dev
cluster (dev
is only a reference to a cluster-name or context that is a lot longer):- Check somehow if the user has access to
dev
cluster: check if the$HOME/.aws/credentials
file contains a token OR useaws sts get-caller-identity
OR something similar - If user has no access to
dev
cluster, acquire access - Switch k8s context
- Get the secret using
kubectl get secret name-of-the-secret-store -o jsonpath='{.path.to.secret}' | base64 -d
- Check somehow if the user has access to
- All of these steps should be done by a wrapper script and the one should call the next one and pass the relevant args, like the short reference (
dev
) to the context.
- Getting a secret from a k8s secret-store in a
- The point would be to have a simple oneliner for
kubectl
commands and the oneliner should be controllable easily with a positional argument that specifies the context in a short form (e.gdev
instead ofvery-long-k8s-dev-context-name-that-is-hard-to-remember
)
Tool which prepares variables for hurl requests in version controlled API collections which are structured into folders.
.env-.*
files in the file tree (from API collection repo root to 'leaf' folders) should be parsed for variables and those variables should be dumped into request.variables
files inside 'leaf' folders of the folder structure.
- sensitive data should be handled in a secure way (e.g. it should not come from
.env-.*
files, it should not be in the repo) -
request.variables
files should be added to.gitignore
automatically
A script which automatically installs and configures a bunch of tools that I use on Ubuntu. It should use Ansible recipes to install/configure a tool.
As input, the script should use a Markdown file which describes the desired system configuration. As a first step, this file should be a checklist kinda thing which contains the list of software that I want to be installed.
Example:
# Programming languages
[x] java:21
[ ] java:17
# DevOps related
## Containerization
[x] Docker
## Kubernetes related
[x] kubectl
[x] kind
[ ] microk8s
Using the above example as input, the script would:
- install Java JDK version 21 and configure stuff like
$JAVA_HOME
- skip the installation of Java 17 (as this component was not "ticked")
- install docker-ce latest version and configure stuff
- install kubectl
- install kind and before doing so, install Go (+ do Go's config) which is a dependency of kind
- skip the installation of microk8s
Every line starting with a [ ]
or [x]
should represent an Ansible playbook which has to be executed.
If Ansible is not installed, it should install it, as a very first step.
Relates resources