This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_name_function() { | |
# There aren't many use cases where we would really want to do things this | |
# way instead of just using a global. Unless we are writing libraries in bash (the horror) | |
# or have an extremely large script where we are not sure we won't be clobbering | |
# variable names (equally terrifying) | |
local __assign_my_results_to_this_variable=$1 | |
local do_some_work=$(echo $ALL_MY_COMMANDS_NAMES | grep -v "bad commands") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If for some insane reason we really want to inspect the bash callstack | |
# we can use the BASH_LINENO, BASH_SOURCE and FUNCNAME variables | |
my_function() { | |
echo "My Function Name: ${FUNCNAME[0]}, I am at line ${BASH_LINENO[0]} of file ${BASH_SOURCE[0]}" | |
# Unless we call this from deeper down, we will get `main`, line 0, and the same filename as before | |
echo "My Parent Function: ${FUNCNAME[1]} is at line ${BASH_LINENO[1]} of file ${BASH_SOURCE[1]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: yipit_data_volume | |
# Recipe:: default | |
# | |
# Copyright 2012, Yipit.com | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
require 'rubygems' | |
require 'chef/log' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Company: Yipit.com | |
# Copyright 2012 | |
# Author: Andrew Gross | |
actions :create, :check, :repair, :destroy | |
default_action :create | |
attribute :chunk, :kind_of => Integer, :default => 256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: yipit_data_volume | |
# Recipe:: default | |
# | |
# Copyright 2012, Yipit.com | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action :create do | |
unless @current_resource.exists | |
command = "yes | mdadm --create #{@new_resource.raid_device} --chunk=#{@new_resource.chunk} --level #{@new_resource.level} --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}" | |
# Check the mdadm raid registry | |
# Existing raids will show as active or inactive | |
# Take the name of the raid array | |
find_current_raid_arrays_command = "cat /proc/mdstat | grep active | awk '{print $1}'" | |
Chef::Log.debug("#{@new_resource} mdadm command: #{command}") | |
attempts = 0 | |
previous_raid_arrays = shell_out!(find_current_raid_arrays_command).stdout.split() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git "update #{program}" do | |
user node['username'] | |
group node['username'] | |
repository "[email protected]:Yipit/#{program}.git" | |
reference branch | |
destination "/var/www/#{program}" | |
ssh_wrapper "/home/#{node['username']}/.ssh/#{program}_ssh_wrapper.sh" | |
action :sync | |
ignore_failure true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef::Knife::Ec2ServerCreate < Chef::Knife | |
def bootstrap_for_node(server, unknownarg) | |
bootstrap = Chef::Knife::Bootstrap.new | |
bootstrap.name_args = [vpc_mode? ? server.private_ip_address : server.dns_name ] | |
bootstrap.config[:run_list] = config[:run_list] | |
bootstrap.config[:ssh_user] = config[:ssh_user] | |
bootstrap.config[:identity_file] = config[:identity_file] | |
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id | |
bootstrap.config[:prerelease] = config[:prerelease] | |
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fri, 14 Sep 2012 17:05:28 +0000] INFO: Processing gem_package[remote_syslog] action install (papertrail::default line 27) | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] using gem from running ruby environment | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] found installed gem remote_syslog version 1.6.5 matching remote_syslog (>= 0) | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] is already installed - nothing to do | |
[Fri, 14 Sep 2012 17:05:28 +0000] INFO: Processing gem_package[remote_syslog] action upgrade (papertrail::default line 27) | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] using gem from running ruby environment | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] found installed gem remote_syslog version 1.6.5 matching remote_syslog (>= 0) | |
[Fri, 14 Sep 2012 17:05:28 +0000] DEBUG: gem_package[remote_syslog] no candidate version - nothing to do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
import sys | |
import time | |
from boto.ec2.connection import EC2Connection | |
from chef import ChefAPI, Node | |
SSH_CONFIG_BLOCK = """ |