Skip to content

Instantly share code, notes, and snippets.

@stefhen
stefhen / md5.md
Last active January 3, 2018 16:22
Convert md5 output to 128-bit md5
echo -n "hello world" | md5sum
5eb63bbbe01eeed093cb22bb8f5acdc3
echo -n "hello world" | openssl md5 -binary | base64
XrY7u+Ae7tCTyyK7j1rNww==
@stefhen
stefhen / provision.cat.rb
Created May 5, 2017 15:58
Provision CAT resources but do not launch
concurrent do
sub do
$server_obj = to_object(@server_1)
@server_1 = rs_cm.servers.create(server: $server_obj["fields"])
end
sub do
$array_obj = to_object(@server_array_1)
@server_array_1 = rs_cm.server_arrays.create(server_array: $array_obj["fields"])
end
end
@stefhen
stefhen / haproxy.rb
Last active March 9, 2017 20:38
generate haproxy.cfg with chef
# Wrapper cookbook snippet and upstream cookbook here: https://github.com/sous-chefs/haproxy
haproxy_lb 'backend-service-name-here' do
params([
'bind 0.0.0.0:80',
'mode http',
'balance roundrobin',
'option forwardfor',
'option http-server-close'
])
Action Href Resource
======================= =========================================================================================== =============================
accounts /api/sessions Session
----------------------- ------------------------------------------------------------------------------------------- -----------------------------
append /api/audit_entries/:id AuditEntry
----------------------- ------------------------------------------------------------------------------------------- -----------------------------
by_resource /api/tags/by_resource Tag
----------------------- ------------------------------------------------------------------
@stefhen
stefhen / gist:5b3cf11b52eb7764fee7a7d30430bb2a
Created January 9, 2017 16:50
Convert putty ssh keys to openssh format
@stefhen
stefhen / pubkey.txt
Created January 4, 2017 16:10
gpg pubkey
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQGiBEpw8r8RBACiH14HYG8a5gqcimctMxaJ+axSqzszIUsIXR4NlvjBaXXcIjOE
GfeCgi1MWPx1khRrRXD3UFDYqyO1oaKqSXY1TEss9ENmeAr0YtltsBLzgdkzIsS6
TS+pfHbazBY2fIXDpa9I3FOL/M5z08bUL8Qtt4it9WVcutnM2DySwWS3rwCg0hC1
i8WZniIGGTbt2inKtwR4w+UD/jZvYUTW8k8quHlj6aVqhKVVg34HpPHCz4HGqetw
jARO2pGujshDdeUuLKEUKGAwVc8u+3mju8OsqQh61esnG7CPGS446WqFYjvk7Pci
ZtRxGQCCuWmGA+/mLFDZjk8FxWfj+cHKU7jWlp+zcFmzkWM5IcNL5lEBFTpS09pK
Kl3oBACAXwZ2Y4eBG3GWsTjJRKEUyypbNVXfsO4O/ej9pi6AbRKhaifdF9y04kzb
@stefhen
stefhen / haproxy-socat.sh
Last active November 11, 2016 20:12
socat haproxy
#!/bin/sh
sock='/var/run/haproxy.sock'
host="${COLLECTD_HOSTNAME}"
pause="${COLLECTD_INTERVAL:-10}"
while getopts "h:p:s:" c; do
case $c in
h) host=$OPTARG;;
p) pause=$OPTARG;;
@stefhen
stefhen / reload-ohai.md
Last active November 8, 2016 22:33
Reload ohai data after creating user and get its uid
  • Chef store all users in the node object under the key etc.

  • Also use lazy evaluation and you don't need a ruby_block

  • This tree is populated by ohai at start of run, so to update it and be able to access node['etc']['passwd']['myuser']['uid'] you have to ask ohai to run the etc plugin again like this:

ohai 'reload_passwd' do
  action :nothing
 plugin 'etc'
@stefhen
stefhen / 00-steps.md
Last active November 14, 2016 20:47
Create RightScale alert via rsc cli tool
  • Append additional collectd metric to /etc/collectd.conf TypesDb line
  • Find instance self via rsc.txt command above
@stefhen
stefhen / s3.json
Last active March 9, 2017 20:39
Grant access to a single s3 bucket and nothing else.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1475614069000",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [