Skip to content

Instantly share code, notes, and snippets.

View grrywlsn's full-sized avatar

Garry grrywlsn

View GitHub Profile
#!/bin/bash
#
# Updates security groups with IP addresses within the AWS account
# https://github.com/grrywlsn/autoawsgroups
# MetaBroadcast.com
IFS="
"
@grrywlsn
grrywlsn / apache.filter
Created October 17, 2014 15:37
Logstash filtering for Apache
input {
redis {
host => '127.0.0.1'
port => '6379'
data_type => 'list'
key => 'logstash'
}
}
filter {
@grrywlsn
grrywlsn / nginx-vhost-atlas
Last active August 29, 2015 14:09
Example Nginx vhost for Atlas
server {
listen *:80 default_server;
server_name _;
resolver 127.0.0.1;
resolver_timeout 10s;
access_log /var/log/nginx/atlas-access.log;
error_log /var/log/nginx/atlas-error.log;
@grrywlsn
grrywlsn / attach-ebs
Created January 4, 2015 21:16
attach-ebs
#! /bin/bash
USERDATA=`ec2metadata --user-data`
AVAILABILITY_ZONE=`ec2metadata --availability-zone`
INSTANCE_ID=`ec2metadata --instance-id`
SPLIT_CHAR="|"
attach_volume() { # $1=instance Id, $2=device path, $3=volume Id
echo "Attaching volume $3 to instance $1 on path $2"
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'set'
require 'pp'
require 'resolv'
$replicaSet = "<%= instance_tag %>" # puppet will fill this in with the correct replicaset tag for this cluster
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
# Om nom nom cookies
#
add_header 'Access-Control-Allow-Credentials' 'true';
@grrywlsn
grrywlsn / proxy-s3.nginx
Created June 6, 2016 22:47
Proxying Nginx to S3
location ~* ^/(.*) {
set $s3_bucket = "<bucket-name>.s3-website-eu-west-1.amazonaws.com";
proxy_http_version 1.1;
proxy_buffering off;
proxy_ignore_headers "Set-Cookie";
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-s3cmd-attrs;
@grrywlsn
grrywlsn / cloud-init
Created July 5, 2016 23:53
cloud-init script for AWS CentOS to use Ansible-Pull on startup
#!/bin/bash
# Set this script as the AWS user-data for a fresh CentOS AMI
# It will be run on startup, and logs to /var/log/cloud-init.log
rpm -iUvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y update
yum -y install epel-release
yum -y install ansible
yum -y install git
mkdir -p /home/centos/.ssh
cat <<EOF > /home/centos/.ssh/id_rsa
@grrywlsn
grrywlsn / local.yml
Created July 6, 2016 00:00
local.yml to set up a new image on first Ansible-Pull
---
- hosts: localhost
tasks:
- name: get ec2 facts
action: ec2_facts
- name: list tags on an instance
ec2_tag:
region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}"
@grrywlsn
grrywlsn / etcd2-cluster-master
Created September 29, 2016 16:24
AWS user-data cloud-config for autoscaling etcd2 masters
coreos:
flannel:
interface: $private_ipv4
etcd_endpoints: http://127.0.0.1:2379
etcd2:
advertise-client-urls: http://$private_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://$private_ipv4:2380
units: