Skip to content

Instantly share code, notes, and snippets.

View willthames's full-sized avatar

Will Thames willthames

View GitHub Profile
@willthames
willthames / dummy
Created February 10, 2014 09:37
Ansible library path merging example
#!/usr/bin/python
import json
print json.dumps({'hello': 'world'})
@willthames
willthames / hosts
Last active August 29, 2015 13:57
Accidentally defining a group containing a group as a group containing a host raises no error (even though there will be a host and a group with the same names).
[group-a:children]
group-b
# here group-c is actually a host because of the missing :children
[group-b]
group-c
# as a result, host-c is also a host, but doesn't belong to group-b (or group-a)
[group-c]
host-c
@willthames
willthames / npm_test.yml
Created March 22, 2014 00:57
NPM improvements
- hosts: localhost
connection: local
tasks:
- npm: name="{{item}}" path="{{installdir}}/A" global=no
with_items:
- hubot
- coffee-script
- npm: name="{{item}}" path="{{installdir}}/B" global=no
@willthames
willthames / gist:afbaaab0c9681ed45619
Last active August 29, 2015 14:06
Recreating pull requests from ansible to ansible-modules-core
git checkout branch_containing_your_commit
git rebase f35ed8a6c0dc81 # last commit before the removal of library modules
git format-patch f35ed8a6c0dc81 --stdout > /tmp/patchname.patch
git checkout devel
cd lib/ansible/modules/core/
git checkout -b branch_for_new_pull_request 417309a626 # this is before the module renames
git am -p2 /tmp/patchname.patch # -p2 here strips off the leading directory (in most cases, library)
git rebase devel
git push your_remote_for_your_fork branch_for_new_pull_request
@willthames
willthames / effortvalue.py
Created April 2, 2012 10:25
Use matplotlib, pandas, numpy etc to plot an effort vs value CSV file
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from pandas import *
from pylab import figure, show
def trimnum(n):
if abs(n - int(n)) > 0.05:
return "%.1f" % n
@willthames
willthames / training.py
Created April 25, 2012 08:32
Graph three pre-marathon run volumes
import numpy as np
from pandas import *
import matplotlib.pyplot as plt
from pylab import figure, show
from datetime import timedelta
df = read_csv('training.csv', sep = ' , ',
names=[ 'date', 'activity', 'distance', 'duration'])
df['date'] = df['date'].apply(lambda x: datetime.strptime(x, '%d/%m/%Y'))
hello {{ who }}
@willthames
willthames / output
Created November 1, 2013 03:58
Demonstration of long running script
[will@tangerine nohup-test]$ ansible-playbook playbook.yml --limit 127.0.0.1
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [run long running script] ***********************************************
^CTraceback (most recent call last):
File "/home/will/src/ansible/bin/ansible-playbook", line 268, in <module>
@willthames
willthames / command
Created May 13, 2016 00:33
ansible register test
ansible-playbook hostname.yml -e hosts=some_ansible_group -vv
#!/usr/bin/env python
import collections
import json
import os
import sys
''' location returns the location portion of the hostname '''
def location(host):