Skip to content

Instantly share code, notes, and snippets.

View mafonso's full-sized avatar

Miguel Afonso mafonso

View GitHub Profile
@mafonso
mafonso / cluster.conf
Last active August 27, 2015 20:40
RedHat Cluster Suite Postgres
<?xml version="1.0"?>
<cluster config_version="7" name="pgcluster">
<clusternodes>
<clusternode name="10.39.30.11" votes="1" nodeid="1">
<fence/>
</clusternode>
<clusternode name="10.39.30.12" votes="1" nodeid="2">
<fence/>
</clusternode>
</clusternodes>
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@mafonso
mafonso / gist:b34cfa7a81a3f7cdec62
Created November 12, 2015 15:48
Consul template to scan all services
# Consul Services
{{range services}}
backend {{.Name}}
balance roundrobin
option redispatch
option forwardfor
{{range service .Name}} server {{.Name}} {{.Address}}:{{.Port}}
{{end}} {{end}}
#End Consul services
@mafonso
mafonso / ssh_commands
Last active December 1, 2015 15:28
Random SSH commands
# Generate public key from private
ssh-keygen -f id_rsa -y > id_rsa.pub
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
export AWS_ACCESS_KEY_ID=${aws_access_key_id}
export AWS_SECRET_ACCESS_KEY=${aws_secret_access_key}
2016/12/06 14:31:58.477298 [INFO] consul-template v0.16.0
2016/12/06 14:31:58.477321 [INFO] (runner) creating new runner (dry: false, once: false)
2016/12/06 14:31:58.477615 [DEBUG] (runner) final config (tokens suppressed):
{
"Path": "/usr/local/consul-template/config/nginx.hcl",
"Consul": "172.17.0.1:8500",
"Token": "",
"ReloadSignal": 1,
"DumpSignal": 3,
On Vault:
$ vault auth-enable aws-ec2
Successfully enabled 'aws-ec2' at 'aws-ec2'!
Error applying plan:
1 error(s) occurred:
* module.postgres.aws_db_instance.instance: aws_db_instance.instance: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.9.2
Resource ID: aws_db_instance.instance
@mafonso
mafonso / Gziped serde
Created June 15, 2018 16:51
ALB Logs Athena
CREATE EXTERNAL TABLE IF NOT EXISTS alb_logs (
type string,
time string,
elb string,
client_ip string,
client_port int,
target_ip string,
target_port int,
request_processing_time double,
target_processing_time double,
@mafonso
mafonso / ssl frontend
Created June 18, 2018 11:43
HAProxy examples
frontend app1_ssl
bind *:443 ssl crt /etc/haproxy/certs.d/example.com.crt crt /etc/haproxy/certs.d/ no-sslv3
option http-server-close
option forwardfor
reqadd X-Forwarded-Proto:\ https
reqadd X-Forwarded-Port:\ 443
# set HTTP Strict Transport Security (HTST) header
rspadd Strict-Transport-Security:\ max-age=15768000