Skip to content

Instantly share code, notes, and snippets.

View nabeken's full-sized avatar

Tanabe Ken-ichi nabeken

View GitHub Profile
@timdiggins
timdiggins / chef-roles-to-json-task.rb
Created February 19, 2011 06:53
rake task to convert existing ruby roles to json
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')
@jtimberman
jtimberman / install.sh
Created October 25, 2012 18:49
COOK-1406
apt-get install -y build-essential
apt-get build-dep -y postgresql
wget http://ftp.postgresql.org/pub/source/v9.2.1/postgresql-9.2.1.tar.gz
tar -zxvf postgresql-9.2.1.tar.gz
cd postgresql-9.2.1
export MAJOR_VER=9.2
./configure \
--prefix=/opt/chef/embedded \
--mandir=/opt/chef/embedded/share/postgresql/${MAJOR_VER}/man \
--docdir=/opt/chef/embedded/share/doc/postgresql-doc-${MAJOR_VER} \
@aaronjensen
aaronjensen / edit_data_bag.rb
Created November 21, 2012 04:39
Edit encrypted data bags for use with chef-solo and knife-solo
#!/usr/bin/env ruby
Dir.chdir File.join(__FILE__, "../..")
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
exit 1
end
unless ARGV.count == 2
@floydpink
floydpink / travis-secure-key-mac.sh
Last active March 6, 2021 22:18 — forked from lukewpatterson/gist:4242707
Generating secure environment variables for GitHub deployment keys to be used from a Travis-CI build.
# On a Mac, use this script to generate secure deployment key
# To generate secure SSH deploy key for a github repo to be used from Travis
base64 --break=0 ~/.ssh/id_rsa_deploy > ~/.ssh/id_rsa_deploy_base64
ENCRYPTION_FILTER="echo \$(echo \"- secure: \")\$(travis encrypt \"\$FILE='\`cat $FILE\`'\" -r floydpink/harimenon.com)"
# If you don't have homebrew please install it from http://brew.sh/
brew install coreutils
gsplit --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_deploy_base64 id_rsa_
# To reconstitute the private SSH key from within the Travis-CI build (typically from 'before_script')
@fnichol
fnichol / .kitchen.yml
Last active February 14, 2018 21:03
Test Kitchen Encrypted Data Bags
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
platforms:
- name: ubuntu-12.04-solo
driver_config:
box: opscode-ubuntu-12.04
provisioner: chef_solo
#!/usr/bin/env ruby
require 'json'
require 'slop'
require 'chef/encrypted_data_bag_item'
def usage
"Load JSON from STDIN and then convert JSON to encrypt data bag.
Usage: #{File.basename(__FILE__)} -s [secret_file]"
end
@philips
philips / user-data
Last active September 16, 2020 14:19
Running consul on top of CoreOS utilizing etcd for automatic bootstrapping.
#!/bin/bash
source /etc/environment
name=$(cat /etc/machine-id)
if [ ! -f /opt/consul ]; then
mkdir /opt
mkdir /var/lib/consul
curl http://storage.googleapis.com/ifup-org-tilde/consul-0.2.0-linux-x86-64.lzma | lzcat > /opt/consul
chmod +x /opt/consul
@dedene
dedene / bootstrap-consul
Last active August 29, 2015 14:04 — forked from philips/user-data
#!/bin/bash
source /etc/environment
name=$(cat /etc/machine-id)
if [ ! -f /opt/consul ]; then
mkdir /opt
mkdir /var/lib/consul
wget https://dl.bintray.com/mitchellh/consul/0.3.1_linux_amd64.zip
unzip 0.3.1_linux_amd64.zip
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@vgeshel
vgeshel / function.js
Last active February 9, 2022 09:19
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};