Skip to content

Instantly share code, notes, and snippets.

View lusis's full-sized avatar

John E. Vincent lusis

View GitHub Profile
import argparse
from mock import Mock
m = Mock()
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
query_group = subparsers.add_parser('query')
add_group = subparsers.add_parser('add')
@lusis
lusis / cloudstack-centos6.conf
Created March 24, 2012 05:04
fairly unsafe cloudstack upstart script to set hostname
# cloudstack - Changes hostname
#
# changes hostname to match cloudstack instance name
# centos version (tested on CentOS 6)
description "Changes hostname"
start on started network
task
# Do a bunch of shit that should only happen at initial setup
# file: cookbooks/foo/recipes/bootstrap.rb
# initial runlist role[foo],recipe[foo::bootstrap]
# useful for downloading an initial codebase of an application
# as opposed to attempting to reinstall each time
ruby_block "remove_bootstrap_recipe" do
block do
Chef::Log.info("Removing foo boostrap from runlist")
node.run_list.remove("recipe[foo::bootstrap]") if node.run_list.include?("recipe[foo::bootstrap]")
@lusis
lusis / dba-user.json
Created January 7, 2011 11:24
Managing MySQL user accounts with Chef
{
"id":"dbauser",
"uid":506,
"comment":"DBA User",
"shell":"/bin/bash",
"groups": [
"sysadm",
"dba"
],
"ssh_key": "XXXXXXXXXX"
# run with
# chef-apply chef-rundeck.rb
require 'chef'
require 'chef/node'
require 'chef/mixin/xml_escape'
require 'chef/rest'
require 'chef/role'
require 'chef/environment'
require 'chef/data_bag'
package fooservice
import (
"github.com/segmentio/ksuid"
idgen "github.com/lusis/foobar/idgen"
pb "github.com/lusis/foobar/pb"
storer "github.com/lusis/foobar/storer"
)
@lusis
lusis / iam-s3-policy.json
Created January 5, 2011 10:32
A sample AWS IAM json policy file with read-only access to certain S3 buckets
{
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
"Resource":["arn:aws:s3:::my_bucket/*","arn:aws:s3:::my_bucket"]
}
],
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
@lusis
lusis / package.sh
Created February 26, 2013 05:17
Generate system packages with FPM as part of maven.
#!/usr/bin/env bash
if [ -z ${CURRENT_ITERATION} ]; then
CURRENT_ITERATION=0enstratus1
fi
case "${PKG_VERSION}" in
*-SNAPSHOT)
echo "Packaging a snapshot version!"
CURRENT_TSTAMP=`date +%s`
#CURRENT_SHA=`git rev-parse HEAD`
#CURRENT_ITERATION="${CURRENT_TSTAMP}-${CURRENT_SHA}"
@lusis
lusis / README.md
Last active September 14, 2020 17:47
terraform template to generate serverspec properties

This uses terraform's template_file resource to generate a yaml properties file for serverspec to use.

  • create the Rakefile in your terraform project root
  • create a spec directory and put spec_helper.rb in it
  • create the templates/properties.tmpl.yml file
  • create the serverspec.tf
  • terraform apply

tests

Tests will be matched based on roles defined for a given node.

@lusis
lusis / keytool.rb
Created March 26, 2012 04:51
recipe for adding certs to keytool
keystore = "/etc/java-6-sun/security/cacerts"
keystore_pass = "foobar"
# you'll need foo.cert et. al. in files/default
certs = %w{foo bar bang}
certs.each do |cert|
cookbook_file "#{Chef::Config[:file_cache_path]}/#{cert}.cert" do
source "#{cert}.cert"
end