Skip to content

Instantly share code, notes, and snippets.

View mriddle's full-sized avatar

Matthew Riddle mriddle

View GitHub Profile
@mriddle
mriddle / README.md
Created December 13, 2012 11:58
Upgradinate - How to upgrade while staying close to master

Upgrading like a baws

upgradinate_script.rb

  helper = UpgradinateFileHelper.new 'OLD NESS', 'NEW-NESS'
  helper.upgradinate_files [
      "/path/to/project/Gemfile"
 ]
@mriddle
mriddle / set_name_of_ec2_instance_with_ami.sh
Created November 12, 2012 23:23
How to set name tag on multiple EC2 instances for given AMI
for instance in `ec2-describe-instances | grep ami-80dd59e9 | grep '^INSTANCE' | cut -f2 -s`; do
ec2-create-tags $instance --tag "Name=Foobar"
done
@mriddle
mriddle / jenkins_copying_configuration.sh
Created November 9, 2012 03:13
Moving Jenkins server configuration from one server to another
ORIGINAL_JENKINS_SERVER=
ORIGINAL_SERVER_USER=
NEW_JENKINS_SERVER=
NEW_SERVER_USER=
# ON THE ORIGINAL JENKINS SERVER
ssh $ORIGINAL_SERVER_USER@$ORIGINAL_JENKINS_SERVER
cd /var/lib/jenkins/
for i in `ls jobs`; do echo "jobs/$i/config.xml";done > config.totar
@mriddle
mriddle / chef_server.init
Created November 9, 2012 00:11
Creating and setting up a chef server
#cloud-config
output:
all: ">> /var/log/cloud-init.log"
# the chef server's alias will be "chef", add a /etc/hosts entry for it
bootcmd:
- echo 127.0.0.1 chef >> /etc/hosts
apt_sources:
@mriddle
mriddle / chef_troubleshooting.md
Created November 8, 2012 21:25
Troubleshooting chef, clients and recipes

Troubleshooting a chef client/recipe

Debugging Chef with Shef

When the chef client fails to run the recipe successfully during bootstrapping sudo chef-client to setup the connection with the chef-server. It will run with an empty run list. After its connected login to http://yourchefserver.com:4040/nodes/_NODE_NAME_, add the roles/recipes to the chef-client and run sudo chef-client from the client again.

When fixing a recipe and re-running make your modifications run knife cookbook upload -a #or cookbook name from your dev machine and run sudo chef-client from the chef client.

When there are issues registering the client with the chef-server check that the chef-client name isn't already registered on the server under clients or nodes or that the client has not already been registered (see below)

@mriddle
mriddle / knife_basics.md
Last active July 20, 2019 19:09
Using knife

Using Knife

Basic configuration

How to knife the chef

  • Uploading cookbooks
    knife cookbook upload -a
    Will upload all cookbooks
  • Updating cookbooks from source
    knife cookbook site vendor cookbook_name # e.g. jenkins
  • Adding roles knife role from file path/filename.ext #e.g. roles/jenkins_node.json
@mriddle
mriddle / knife.rb
Created November 8, 2012 20:56
Basic knife configuration for chef server
### Chef Knife config example
# https://github.com/fnichol/chef-bootstrap-repo/blob/master/.chef/knife.rb
###
# Environment variables required:
# CHEF_SERVER_URL - IP or url of your chef server
# CHEF_USER - Initial user
# AWS_ACCESS_KEY - AWS Access ID found here https://portal.aws.amazon.com/gp/aws/securityCredentials
# AWS_SECRET_KEY - AWS Secrete key found in link above
#!/usr/bin/env bash
set -e
set -x
### How To Use
#
# sudo bash -c 'bash \
# <(curl -sLB https://raw.github.com/gist/1209226/bootstrap_chef_server.sh) \
# --hostname foo.example.com'
#
@mriddle
mriddle / show-remote-branch-info.sh
Created October 4, 2012 22:19 — forked from michaelkirk/show-remote-branch-info.sh
sort remote branches by age
#!/bin/sh
#
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
#
# Folks at pivotal shared this with me
#
#$ . show-remote-branch-info.sh
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill
@mriddle
mriddle / gist:3824002
Created October 2, 2012 23:35
Formtastic custom html_safe input
## html_safe_intput.rb
# encoding: UTF-8
class HtmlSafeInput < Formtastic::Inputs::TextInput
# Called dynamically, via form.input :foo, :as => :html_safe
def to_html
return super if object[method].blank?
input_wrapping do
label_html <<