Skip to content

Instantly share code, notes, and snippets.

View mgoodness's full-sized avatar

Michael Goodness mgoodness

View GitHub Profile
@mgoodness
mgoodness / access_dbs.py
Created July 14, 2015 13:41
Script to check file sizes and send email if approaching max_size
#!/usr/bin/python
import os
import smtplib
import time
from email.mime.text import MIMEText
access_dbs = [
{'location':'/srv/data/apps/Access/Data/Jobtrack/JobTrackData.mdb',
@mgoodness
mgoodness / rsync-snapshot.sh
Created July 14, 2015 20:32
Script for backing up from multiple locations via rsync using hardlinks
#!/bin/bash
# *** Accepts two optional arguments
# -tDATE: today's date (ISO-8601, yyyy-mm-dd)
# -yDATE: yesterday's date (ISO-8601, yyyy-mm-dd)
#
# Use these if a nightly backup is missed.
# "Yesterday's date" should be the date of the last successful backup.
# Otherwise --link-dest will fail and rsync will do a full copy
# instead of a diff.
@mgoodness
mgoodness / reflect.py
Created November 10, 2015 17:19
Python HTTP server that echos GET requests
#!/usr/bin/env python
# Reflects the requests from HTTP GET methods
# Written by Nathan Hamiel (2010), modified by Michael Goodness (2015)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from argparse import ArgumentParser
from urlparse import urlparse
import daemon
import socket
@mgoodness
mgoodness / var-lib-etcd2.mount
Last active July 20, 2020 12:29
Systemd unit file to mount EBS volume to /var/etc/data
[Unit]
Description=Mount EBS volume at /var/lib/etcd2
Requires=format-etcd-ebs.service
After=format-etcd-ebs.service
Before=etcd2.service
[Mount]
DirectoryMode=0777
Type=ext4
What=/dev/xvdb
@mgoodness
mgoodness / format-etcd-ebs.service
Last active January 2, 2021 22:08
Systemd unit file to format EBS volume
[Unit]
Description=Format EBS volume if needed
Before=etcd2.service
[Service]
ExecStart=/bin/bash -c \
'(/usr/sbin/blkid -t TYPE=ext4 | grep /dev/xvdb) || \
(/usr/sbin/wipefs -fa /dev/xvdb && /usr/sbin/mkfs.ext4 /dev/xvdb)'
RemainAfterExit=yes
Type=oneshot
@mgoodness
mgoodness / asp.sh
Last active October 14, 2021 08:36
Bash/Zsh function for switching AWS profiles (supports sts assume-role)
function asp {
if [[ -z "$1" ]]; then
if [[ -z "$AWS_DEFAULT_PROFILE" ]]; then
echo "No profile set"
else
asp "$AWS_DEFAULT_PROFILE"
echo "$AWS_DEFAULT_PROFILE"
fi
else
if ! fgrep -q "[profile $1]" ~/.aws/config; then
@mgoodness
mgoodness / aws-credentials
Last active August 18, 2016 14:17
Example AWS credentials file for Java SDK-compatible role assumption
[default]
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>
[prod]
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<PROD_ROLE_NAME>
source_profile = default
[stage]
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<STAGE_ROLE_NAME>
@mgoodness
mgoodness / aws-config
Last active August 18, 2016 14:17
Example AWS config file
[profile default]
output = json
region = us-east-1
[profile prod]
output = json
region = us-east-1
[profile stage]
output = json

Keybase proof

I hereby claim:

  • I am mgoodness on github.
  • I am mgoodness (https://keybase.io/mgoodness) on keybase.
  • I have a public key ASDT8fGpKWmps-o_HhjIM5NNTlPN3CQFs48vZEHFhOa5eQo

To claim this, I am signing this object:

@mgoodness
mgoodness / k8s-svc-annotations.md
Last active March 11, 2024 16:24
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags (comma-separated list of key=value)
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)