Giter Site home page Giter Site logo

scripts's Introduction

scripts

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.

Some rules for scripting

  • 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 have bash.
  • 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.

Initial goals

  • 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

Future script ideas

Wrappers for kubectl commands

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):
      1. Check somehow if the user has access to dev cluster: check if the $HOME/.aws/credentials file contains a token OR use aws sts get-caller-identity OR something similar
      2. If user has no access to dev cluster, acquire access
      3. Switch k8s context
      4. Get the secret using kubectl get secret name-of-the-secret-store -o jsonpath='{.path.to.secret}' | base64 -d
    • 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.
  • 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.g dev instead of very-long-k8s-dev-context-name-that-is-hard-to-remember)

Prepare variables for hurl requests

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

Ubuntu system setup script using Ansible playbooks

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

scripts's People

Contributors

feketebence avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.