Skip to content

Instantly share code, notes, and snippets.

View abn's full-sized avatar

Arun Babu Neelicattu abn

View GitHub Profile
@abn
abn / mantl-consul-reset-peers.yml
Created February 15, 2016 02:20
Mantl: Reset consul peers to recover from a cluster outage.
---
# https://www.consul.io/docs/guides/outage.html
# do a rolling restart; be nice to the cluster
- hosts: role=control
serial: 1
gather_facts: no
tasks:
- name: set consul maintenance enable
command: consul maint -enable -reason "{{ lookup('env', 'USER') }} reset consul peers"
@abn
abn / consul-check-docker-storage-health.sh
Created February 4, 2016 16:10
A health script that can be used by consul checks to test if there more than a defined amount of storage available to docker.
#!/usr/bin/env bash
DOCKER_SOCK=${1:-/var/run/docker.sock}
THRESHOLD_GB=${THRESHOLD_GB:2}
if [ ! -S "${DOCKER_SOCK}" ]; then
echo 2>&1 "Docker socket not available at ${DOCKER_SOCK}"
exit 1
fi
@abn
abn / .bashrc.docker.sh
Last active January 16, 2016 08:18
.bashrc additions for docker sugar
# .bashrc.docker
# get id of last container started
docker-last() { docker ps -l -q ;}
# http://www.commandlinefu.com/commands/view/15050/attach-to-bash-shell-in-the-last-container-you-started
docker-exec() { docker exec -i -t $(docker-last) ${@-bash} ;}
# get ip of container with given id (default: last started container)
docker-ip() { docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${1-$(docker-last)} ;}
#!/usr/bin/env bash
mv /usr/bin/uname /usr/bin/uname-host
cat > /usr/bin/uname << EOF
#!/usr/bin/env bash
HOST_KERNEL=\$(uname-host -r)
GUEST_KERNEL=\$(repoquery --qf '%{VERSION}-%{RELEASE}.%{ARCH}' kernel)
@abn
abn / bumpversion-release.sh
Created November 5, 2015 06:28
Example script for bumping a version
#!/usr/bin/env bash
command -v bumpversion >/dev/null 2>&1 || { \
echo >&2 "bumpversion is not installed. Install via 'pip install bumpversion'. Aborting."; \
exit 1; \
}
bumpversion $@ release
bumpversion --no-tag $@ minor
@abn
abn / reachability.py
Last active October 21, 2015 13:07
Test if a list of IP targets are reachable
#!/usr/bin/env python
from sys import argv
from subprocess import check_output, STDOUT
TIMEOUT=1
def ping(target):
@abn
abn / systemd-nfs-automount-fstab.sh
Created September 8, 2015 14:45
NFS share automount via systemd
#!/usr/bin/env bash
NFS_SERVER=${NFS_SERVER-192.168.1.1}
NFS_SHARE=/nfs
NFS_MOUNT=/media/nfs
cat >> /etc/fstab << EOF
${NFS_SERVER}:${NFS_SHARE} ${NFS_MOUNT} nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14 0 0
EOF
@abn
abn / logstash.service
Last active November 30, 2022 13:17
logstash systemd service file
[Unit]
Description=Logstash
Documentation=https://www.elastic.co/products/logstash
After=network.target
ConditionPathExists=/etc/logstash.conf
[Service]
ExecStart=/opt/logstash/bin/logstash agent -f /etc/logstash.conf
[Install]
@abn
abn / Makefile
Created July 20, 2015 06:46
Dockerized centos rpm build makefile
#
# CentOS RPM Builder
# Usage: make build COMPONENT=</path/to/source>
#
TARGET := $(shell pwd)/target
COMPONENT := $(shell pwd)/sources
BUILDER := alectolytic/rpmbuilder-centos
@abn
abn / enable-cockpit-f22.sh
Created June 11, 2015 05:18
Enable cockpit on Fedora 22
#!/usr/bin/env bash
# based on instructions provided at
# http://www.projectatomic.io/blog/2015/06/running-cockpit-as-a-service/
atomic info fedora/cockpitws
atomic install fedora/cockpitws
cat > /etc/systemd/system/cockpitws.service << EOF
[Unit]