Skip to content

Instantly share code, notes, and snippets.

@dalethestirling
dalethestirling / gist:3d98dfb474d1d3ab5f81
Created August 28, 2014 03:14
Kill Google Chrome threads on a mac when hung
ps aux | grep Chrome.app | awk -F ' ' '{ print $2 }' | xargs -I {} kill -9 {}
@dalethestirling
dalethestirling / README.md
Last active August 29, 2015 14:06
Simple config object Python

Here is a simple config object that I though would be worth breaking out so that it can be used for other things.

This is currently implemented in rdiff-backup-web, using a JSON file as the imput.

@dalethestirling
dalethestirling / gist:6be18f9b2add36a839c8
Created September 25, 2014 01:12
Unpack an MSI from CMD prompt
msiexec /a c:\path\to\msi\file.msi /qb TARGETDIR="c:\path\to\output\"

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py

:

@dalethestirling
dalethestirling / inventory.py
Created October 26, 2015 22:19 — forked from duggan/inventory.py
Present Terraform tfstate data as an Ansible inventory
#!/usr/bin/env python
import sys
import os
import json
import argparse
import collections
__description__ = """Ansible Dynamic Inventory for Terraform."""
__epilog__ = """
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@dalethestirling
dalethestirling / README.md
Created September 2, 2016 10:19
Ansible Container HelloWorld

Ansible-continer HelloWorld

Here is a quick ansible-container HelloWorsld deployment running Nginx.

The config creates a single Centos 7 container running nginx exposed on port 8080.

This GIST assumes you have read the ansible-container docs and have a sucessful install of the app and its prerequisits.

Install

  1. Run ansible-container init
@dalethestirling
dalethestirling / docker-compose.yml
Created September 26, 2016 23:56
Docker-compose - Kubernetes on Docker for Mac OSX
etcd:
image: gcr.io/google_containers/etcd:2.2.1
command: ['/usr/local/bin/etcd', '--bind-addr=0.0.0.0:4001', '--data-dir=/var/etcd/data']
apiserver:
image: gcr.io/google_containers/hyperkube:v1.3.7
command: ["/hyperkube", "apiserver", "--service-cluster-ip-range=172.17.17.1/24", "--insecure-bind-address=0.0.0.0", "--etcd_servers=http://etcd:4001", "--v=2"]
ports:
- "8080:8080"
links:
@dalethestirling
dalethestirling / README.md
Last active June 8, 2017 15:13
Association of Route53 private hosted zones between AWS accounts using terraform.

As more solutions are leaveraging AWS accounts as the demarcation line between determined change and fault domains within solutions the association of private Route53 zones between these fault domains has become more difficult. The common senario where this is encountered is when the engineering or SDLC tooling environments DNS needs to be propergated to other environments to facilitate Continious Delivery practices.

This activity is able to be done, not through the console but leaveraging the underlying AWS API as documented by Amazon: https://aws.amazon.com/premiumsupport/knowledge-center/private-hosted-zone-different-account/

This approach is not supported by current versions of Terraform, and current GitHub issues suggest that this could a large amount of work. The easiest way to solve this is to make the required calls using {{ awscli }}. This can be done in terraform in a managed approach using the {{ null_resource }} resource.

Lets imagine that that VPC-A (vpc-a.tf) has hosts that need to be refere

@dalethestirling
dalethestirling / postgres_user.yml
Created September 10, 2017 22:24
Create Postgres DB user using lookup()
- name: Create db users
postgresql_user:
login_host: "{{ hostname }}"
login_user: "{{ db_user }}"
login_password: "{{ db_passwd }}"
db: "{{ db }}"
priv: "{{ db_priv }}"
name: "{{ item }}"
password: "{{ lookup('password', playbook_dir + '/' + db + '-' + item.user + '.passwd') }}"