Instantly share code, notes, and snippets.

View reclass_topology_from_cluster.sh
rm -rf new
mkdir -p new
# set init.yml pointing to default.yml
function i() {
# i() path/top/default.yml
# i() path/top/default
# i() path/top
if [[ "$(basename $1)" == "default" ]]; then
View jq-cheetsheet.md

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

View Terraform_functions.md

Supported built-in functions

  • abs(float) - Returns the absolute value of a given float. Example: abs(1) returns 1, and abs(-1) would also return 1, whereas abs(-3.14) would return 3.14. See also the signum function.

  • basename(path) - Returns the last element of a path.

  • base64decode(string) - Given a base64-encoded string, decodes it and returns the original string.

View maas-squashfs-backdoor.sh
https://gnu-linux.org/building-ubuntu-rootfs-for-arm.html
"2) Extract the downloaded image with ‘sudo’ to allow ‘mknod’ commands to work"
# get a cloud image from here
# https://cloud-images.ubuntu.com/daily/server/xenial/
# https://cloud-images.ubuntu.com/daily/server/xenial/current/
# based on https://bazaar.launchpad.net/~maas-images-maintainers/maas-images/maas-ephemerals/view/head:/bin/img2squashfs#L161
# extract a cloud image rootfs to a directory, sudo is needed for `mknod`s to work
# doesn't have to be .tar.gz - could well unsquashfs an existing squashfs
View sync-classes.sh
#!/bin/bash
# Update local reclass model with system and service classses from container
# Source/Install:
# curl -sqL https://gist.githubusercontent.com/epcim/f42a844bc7f9689dc9a4fd8d03f75dcd/raw/sync-classes.sh -o sync-classes.sh; chmod u+x sync-classes.sh
# Usage:
# ./sync-classes.sh [destination reclass model path] [docker image]
DMODEL=${1:-$PWD}
View parse_yaml.sh
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
View elastic_health.md

HEALTH DETAILS

curl -XGET http://log:9200/_cluster/health?pretty

WHAT ARE THE CUSTOM SETTINGS?

curl -XGET 'log:9200/_cluster/settings?pretty'

HEALTH DETAILS

View gist:2d0d61442a745e9cd5afb85ef8e45aa8
cat terraform.tfstate | jq -r '.modules[0].resources | map(select(.type == "google_compute_instance")) | map([.primary.id, " ansible_ssh_host=", .primary.attributes["network_interface.0.access_config.0.nat_ip"]] | join("")) | sort | .[]'
View docker-compose.yml
version: '3.2'
services:
bastion:
image: christophermaier/test-probe:0.1.0-20180509175222
command:
- "run"
- "--listen-ctl=0.0.0.0:9632"
- "--permanent-peer"
hostname: bastion
domainname: habitat.dev
View Kafka cheet sheets.md

Kafka

get size for all topics on worker

 for topic in $(find   /opt/cloudera/data/*/kafka/ -maxdepth 1 -mindepth 1 -type d -exec basename {} \;| awk -F '-' '{print $1}'| sort |uniq | grep -v consumer_offsets);do

du -csh /opt/cloudera/data/*/kafka/${topic}*| grep total| awk '{print "topic '$topic' "$1}'
done