Skip to content

Instantly share code, notes, and snippets.

View iandelahorne's full-sized avatar

Ian Delahorne iandelahorne

  • San Francisco
  • 12:52 (UTC -07:00)
View GitHub Profile
include_recipe "postgresql_database"
postgresql_database 'test' do
connection { :host => "127.0.0.1", :port => 5432, :username => 'postgres', :password => node['postgresql']['password']['postgres'] }
action :create
provider "postgresql_database"
end
cookbook_file "/opt/cntw/conf/create_cntw.pgsql" do
mode "0644"
owner "root"
group "root"
source "create_cntw.pgsql"
end
#include_recipe "database"
package "cntw-plsqlmodules" do
action [:install, :upgrade]
@iandelahorne
iandelahorne / vsphere_vm_listall.rb
Created March 12, 2012 10:56
knife vsphere vm listall
# Copyright (C) 2012, SCM Ventures AB
# Author: Ian Delahorne <ian@scmventures.se>
#
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* Basic scenario is that we want to hand out static IPs over DHCP
using hostnames provided by the clients. Ideally we could use the
hostname, but I haven't found dhcpd configuration that works, so I
used dhcp-client-identifier instead.
Our setup is:
* VMs get created in VMware by deploying from a template, which is a
base VM image. VMware has limited customization possibilities when
deploying, so it can only really set the hostname and configure
interfaces' IP address / use DHCP.
@iandelahorne
iandelahorne / rename-node.rb
Created August 14, 2012 10:35 — forked from jtimberman/rename-node.rb
A knife exec script to change Chef node's name.
#!./bin/knife exec
# ian-note: run from your home directory. Add the following to your .chef/knife.rb:
# knife[:ssh_user] = "myusername"
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
#
# Author:: Ezra Pagel (<ezra@cpan.org>)
# License:: Apache License, Version 2.0
#
require 'chef/knife'
require 'chef/knife/BaseVsphereCommand'
# Lists all known virtual machines in the configured datacenter
class Chef::Knife::VsphereVmList < Chef::Knife::BaseVsphereCommand
@iandelahorne
iandelahorne / s3.h
Last active December 20, 2015 22:39
#ifndef _S3_H
#define _S3_H
struct s3_string {
char *ptr;
size_t len;
};
struct s3_string * s3_string_init();
size_t s3_string_curl_writefunc(void *ptr, size_t len, size_t nmemb, struct s3_string *s);
@iandelahorne
iandelahorne / sbin.sh
Created November 1, 2013 11:11
/etc/profile.d/sbin.sh
path_elems=(${PATH//:/ })
sbin_missing=1
usr_sbin_missing=1
usr_local_sbin_missing=1
for i in "${!path_elems[@]}" ; do
if [ "${path_elems[i]}" = /sbin ]; then sbin_missing = 0 ; fi
if [ "${path_elems[i]}" = /usr/sbin ]; then usr_sbin_missing = 0 ; fi
if [ "${path_elems[i]}" = /usr/local/sbin ]; then usr_local_sbin_missing = 0 ; fi
done
package main
import (
"code.google.com/p/goauth2/oauth"
urlshortener "code.google.com/p/google-api-go-client/urlshortener/v1"
"flag"
"fmt"
"log"
)
@iandelahorne
iandelahorne / output
Last active August 29, 2015 14:03
Testing gophercloud.ServerById
: ian@Upshot-Knothole go; ./serverbyid
Got JSON body {"itemNotFound": {"message": "Instance could not be found", "code": 404}}
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x304f2]
goroutine 16 [running]:
runtime.panic(0x2aa680, 0x46e8e4)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/rackspace/gophercloud.(*genericServersProvider).ServerById(0xc2081de7b0, 0x2ee450, 0x8, 0x15, 0x0, 0x0)
/Users/ian/go/src/github.com/rackspace/gophercloud/servers.go:103 +0x252