Skip to content

Instantly share code, notes, and snippets.

View odyssey4me's full-sized avatar

Jesse Pretorius odyssey4me

  • Red Hat
  • United Kingdom
View GitHub Profile
#!/usr/bin/ruby
# vim:ts=2:expandtab
require 'net/http'
require 'uri'
require 'json'
#http://wiki.apache.org/couchdb/Compaction
STDOUT.sync = true
print "Checking chef database size."
#!/usr/bin/ruby
# vim:ts=2:expandtab
require 'net/http'
require 'uri'
require 'json'
puts "Current CouchDB active tasks:"
uri = URI.parse("http://localhost:5984/_active_tasks")
res = Net::HTTP.get_response(uri)
puts JSON.pretty_generate(JSON.parse(res.body))
@odyssey4me
odyssey4me / novanet2quantum
Created February 5, 2014 17:14
This is a pseudo-code description of the process to convert nova-network entries to quantum/neutron entries. The idea is based on retrieving the data directly from the nova database and then injecting the appropriate entries via the API into quantum/neutron. It's specific to the use-case of converting vlan-managed nova-network entries to a gre-b…
##### network conversion #####
PUBLIC_NETWORK_UUID=`quantum net-list | grep public | awk '{print $2}'`
foreach row of `select id,project_id,cidr,dns1,dns2 from networks where deleted=0 and project_id is not null;` do
TENANT_ID=project_id
TENANT_NAME=`keystone tenant-list | grep $(TENANT_ID) | awk '{print $4}'`
NETWORK_NAME=$(TENANT_NAME)+'_Network_'+id
SUBNET_NAME=$(TENANT_NAME)+'_Subnet_'+id
if dns1 = NULL then DNS_NAMESERVER1 = '8.8.8.8' else DNS_NAMESERVER1=dns1
if dns2 = NULL then DNS_NAMESERVER2 = '8.8.4.4' else DNS_NAMESERVER2=dns2
SUBNET_CIDR=cidr
@odyssey4me
odyssey4me / timestamp.py
Last active August 29, 2015 14:10
Place into /usr/local/lib/python2.7/dist-packages/ansible/callback_plugins/ in order to see the duration of time for each task and play.
# Based on the examples available at https://github.com/ansible/ansible/tree/devel/plugins/callbacks
# and the similar https://github.com/ginsys/ansible-plugins/blob/devel/callback_plugins/timestamp.py
# imports
import time
from ansible.callbacks import display
# define start time
t0 = tn = time_play_start = time.time()
@odyssey4me
odyssey4me / recipe-thatched_fish_pie.txt
Last active August 29, 2015 14:16
Recipe: Thatched Fish Pie
Serves: 2
Ingredients:
- 300ml skimmed milk
- 1 bay leaf
- 280-300g haddock fillets
- 1 leek
- 1 garlic clove
- a punnet of baby leaf spinach
- 1 tbsp cornflour
@odyssey4me
odyssey4me / ansible.cfg
Last active August 29, 2015 14:16
ansible-dict-merge
[defaults]
jinja2_extensions=jinja2.ext.do
@odyssey4me
odyssey4me / install-logstash-forwarder.sh
Last active August 29, 2015 14:19
Notes for setting up logstash-forwarder as a log shipper to a RPC logstash server
###
### On the Logstash Server
###
# Prepare the server certificate directories
CERT_DIR='/etc/pki/tls'
mkdir -p ${CERT_DIR}/certs
mkdir ${CERT_DIR}/private
# Allow the server IP to be in the certificate subjectAltName
@odyssey4me
odyssey4me / install-python-beaver.sh
Last active August 29, 2015 14:19
Notes for setting up python-beaver as a log shipper to a RPC logstash server
###
### On the Logstash Server
###
# Setup the tcp listener
cat >/etc/logstash/conf.d/01-input.conf <<EOL
#===============================================================================
input {
syslog {
port => 5544
@odyssey4me
odyssey4me / get_adfs_saml_request.xml
Last active August 29, 2015 14:24
Getting an ADFS Token for a Shibboleth SP
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</a:Action>
<a:To s:mustUnderstand="1">ADFS_IDP_ADDRESS/adfs/services/trust/13/UsernameMixed</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" >
<o:UsernameToken u:Id="uuid-6a13a244-dac6-42c1-84c5-cbb345b0c4c4-1">
<o:Username>ADFS_USERNAME</o:Username>
@odyssey4me
odyssey4me / gist:4c40db99f361e2176345
Created July 6, 2015 18:55
when working with ansible <v2, use this to keep your sanity
# change into the root of your repo
# resurrect the ssh_retry plugin for your sanity
mkdir -p playbooks/plugins/connection_plugins/
wget -O playbooks/plugins/connection_plugins/ssh_retry.py \
https://raw.githubusercontent.com/stackforge/os-ansible-deployment/juno/rpc_deployment/plugins/connection_plugins/ssh_retry.py
sed -i '/lookup_plugins/a \ \
# ssh_retry connection plugin \
connection_plugins = plugins/connection_plugins \
transport = ssh_retry' playbooks/ansible.cfg
# now you can execute your playbooks