Skip to content

Instantly share code, notes, and snippets.

View iMilnb's full-sized avatar

iMil iMilnb

View GitHub Profile
@iMilnb
iMilnb / userdata.sh
Last active October 11, 2016 15:45
Transform Debian Jessie AMI to `sysvinit`
# Simply add the following to the Userdata script so the
# instance bootstrap sequence transforms the debian jessie
# systemd init to good old sysvinit.
# initial method from
# http://without-systemd.org/wiki/index.php/How_to_remove_systemd_from_a_Debian_jessie/sid_installation
# but using a safer and actually working `cat ><<EOF` method
apt-get -y install sysvinit-core sysvinit sysvinit-utils
apt-get remove --purge --auto-remove systemd
cat >/etc/apt/preferences.d/systemd<<EOF
Package: systemd
@iMilnb
iMilnb / basic_asg.py
Last active April 23, 2017 13:27
Simple ASG (1:1) creation via Troposphere, providing a CloudFormation JSON template
from troposphere import Template, Ref, Parameter, Tags
from troposphere.autoscaling import LaunchConfiguration, AutoScalingGroup, Tag
t = Template()
params = {
'AmiId': 'Baked AMI Id',
'InstanceName': 'Name tag of the instance',
'SecurityGroup': 'Security Group' ,
'KeyName': 'SSH Key Name' ,
@iMilnb
iMilnb / ddbench.sh
Last active June 5, 2017 22:39
Trivial disk troughput bench using dd(1)
#!/bin/sh
[ $# -lt 1 ] && echo "usage: $0 <path>" && exit 1
bpath=$1
# you might want to change these to suit your setup
bs=32k
count=30000
@iMilnb
iMilnb / gist:b09f45e112b226b97a36
Last active December 4, 2017 12:46
Minimalistic jinja2-based page generator
import sys
import markdown
import yaml
import os
from jinja2 import Environment, FileSystemLoader
with open(sys.argv[2], 'r') as f:
content = yaml.safe_load(f.read())
for k in content:
@iMilnb
iMilnb / bitstamp.go
Created December 21, 2017 22:22
collectd go plugin to fetch Bitstamp prices
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
@iMilnb
iMilnb / vpc_vpn_ec2.py
Last active June 16, 2018 09:23
Dynamic Troposphere + boto3 template that creates a complete and functional VPC through AWS CloudFormation
#!/usr/bin/env python
from troposphere import Join, Output
from troposphere import Parameter, Ref, Tags, Template
from troposphere.ec2 import PortRange
from troposphere.ec2 import NetworkAcl
from troposphere.ec2 import Route
from troposphere.ec2 import VPCGatewayAttachment
from troposphere.ec2 import SubnetRouteTableAssociation
from troposphere.ec2 import Subnet
@iMilnb
iMilnb / gist:ba7b46dfc854544bf3c8
Last active September 4, 2018 19:29
Dynamic ipsec and racoon configuration generation for AWS EC2 VPN using boto3 and Jinja2
#!/usr/bin/env python
# $ cat ipsec_conf.tmpl
# {#
#
# cgw_in_addr: customer_gateway tunnel_inside_address ip_address
# cgw_in_cidr: customer_gateway tunnel_inside_address network_cidr
# vgw_in_addr: vpn_gateway tunnel_inside_address ip_address
# vgw_in_cidr: vpn_gateway tunnel_inside_address network_cidr
# cgw_out_addr: customer_gateway tunnel_outside_address
@iMilnb
iMilnb / aws_sandbox.md
Last active September 26, 2018 16:30
Custom AWS sandbox using packer, Troposphere / CloudFormation and Ansible

packer template

{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": ""
  },
  "builders": [{
    "type": "amazon-ebs",
@iMilnb
iMilnb / collectd.conf
Last active October 10, 2018 21:33
collectd-python plugin to read data from ethermine.org
<Plugin python>
ModulePath "/home/imil/collectd"
Import "ethermine"
<Module ethermine>
wallet "0xf00f00f00"
interval "300"
url "https://ethermine.org/api/miner_new"
</Module>
</Plugin>
@iMilnb
iMilnb / tf_debug.log
Created December 6, 2018 14:09
terraform debug for aws_ses_receipt_rule bug report
terraform apply tfplan
2018/12/06 14:44:36 [INFO] Terraform version: 0.11.10 17850e9a55d33c43d7c31fd6ac122ba97a51d899
2018/12/06 14:44:36 [INFO] Go runtime version: go1.11.1
2018/12/06 14:44:36 [INFO] CLI args: []string{"/home/imil/pkg/bin/terraform", "apply", "tfplan"}
2018/12/06 14:44:36 [DEBUG] Attempting to open CLI config file: /home/imil/.terraformrc
2018/12/06 14:44:36 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/12/06 14:44:36 [INFO] CLI command args: []string{"apply", "tfplan"}
2018/12/06 14:44:36 [INFO] command: initializing local backend from plan (not set)
2018/12/06 14:44:36 [DEBUG] checking for provider in "."
2018/12/06 14:44:36 [DEBUG] checking for provider in "/home/imil/pkg/bin"