Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@sivel
sivel / server_list_generator.py
Last active August 29, 2015 14:05
pyrax server list generator
#!/usr/bin/env python
import pyrax
pyrax.set_setting('identity_type', 'rackspace')
pyrax.set_credentials('myusername', 'myapikey', region='DFW')
def server_list_generator(detailed=True, search_opts=None, limit=None):
servers = pyrax.cloudservers.servers.list(detailed=detailed,
search_opts=search_opts,
limit=limit)
certs:
www_example_com:
key: |
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA0cfBegr0ahA1PXrF3fBJURcBxoP8PZow1a6tRGe3ruJZBMSH
vx2+dm2Sq3bCPHH2hUkC0Oj2U+54WMzn22ZwVsgOPG7ks1EqKy48K5VPrWDMJqjn
MhxLpTaf6xaGUlkVA6xcO5+SNFqzkq8fFWSHmY+E3n03ym0zH/Loy1KYRI0xVPRq
ITp7AoPbJ58Lz1X9CgBd7siaVjPvaS6WfosLwlI8gr1h6vqeO7nPrF8B9HnV7867
bSZlkbb6vqgtLg73B4diRGvNn5X9Kpsi1jbp7DAXHj2pGA8kr8TjV6MG28Di/iWL
oyiBDziIHe7iV0my+wl12x6o5JTuVVMkbD57AQIDAQABAoIBAB3ysoBFyBbMMY2R
@sivel
sivel / drone.sh
Created September 18, 2014 02:13
Drone on RHEL6
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install -y golang git mercurial make bzr
export GOPATH=~/Go
export PATH=$PATH:$GOPATH/bin
mkdir $GOPATH
go get github.com/drone/drone
cd $GOPATH/src/github.com/drone/drone
make deps
make vendor
make clean
@sivel
sivel / email-cmd.py
Created March 20, 2015 00:07
email-cmd.py ansible callback plugin
import os
import sys
import smtplib
def mail(subject='Ansible Command', sender='<root>', to='root', cc=None,
bcc=None, body=None):
if not body:
body = subject
@sivel
sivel / ansible-validate-modules
Last active August 29, 2015 14:21
Ansible module validator
pip install git+https://github.com/ansible/ansible.git@devel#egg=ansible
pip install git+https://github.com/sivel/ansible-testing.git#egg=ansible_testing
git clone https://github.com/ansible/ansible-modules-core.git
ansible-validate-modules ansible-modules-core
@sivel
sivel / rackspace.py
Last active August 29, 2015 14:23
python-openstacksdk Rackspace API Key Authenticator
from openstack.auth.identity.v2 import Password
class ApiKey(Password):
valid_options = {
'access_info',
'auth_url',
'username',
'user_id',
'password',
@sivel
sivel / etc_hosts.py
Created June 22, 2015 18:45
Ansible inventory script that uses /etc/hosts as it's data source
#!/usr/bin/env python
# (c) 2015, Matt Martz <matt@sivel.net>
#
# This file is part of Ansible.
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@sivel
sivel / perm-test.php
Created April 13, 2010 18:59
Test for the minimum file permissions required for the webserver to read a file that it has written
<?php
function perm_test() {
$file = '.perm_test';
@touch( $file );
if ( ! is_readable( $file ) )
return false;
$perms = array( 0666, 0664, 0644, 0660, 0640, 0600, 0444, 0440, 0400 );
$lastperm = 0666;
#!/usr/bin/python
import urllib, re, sys
def content_match(url, match, nocase):
uh = urllib.urlopen(url)
if re.search(match, uh.read(), re.I if nocase else 0) and uh.getcode() == 200:
return [True, uh.geturl(), uh.getcode()]
else:
return [False, uh.geturl(), uh.getcode()]
@sivel
sivel / wp-tag-svn-up.sh
Created May 16, 2011 20:03
Automated WordPress upgrades using SVN tags
#!/bin/bash
TAGSURL='http://core.svn.wordpress.org/tags/'
STABLETAG=`curl -s $TAGSURL | awk -F '">' '{print $2}' | awk -F"/<" '{print $1}' | egrep "^[0-9].[0-9]" | sort -n | tail -n 1`
if [ $STABLETAG == '' ]
then
echo "Stable tag not found, exiting..."
exit 1
fi
for ADDON in `ls -1d /home/user/sites/*/`
do