Skip to content

Instantly share code, notes, and snippets.

View scarolan's full-sized avatar
🤸‍♂️
In whatever position one is in...one must find balance. -BKS Iyengar

Sean Carolan scarolan

🤸‍♂️
In whatever position one is in...one must find balance. -BKS Iyengar
View GitHub Profile
@scarolan
scarolan / gist:7137902
Created October 24, 2013 14:05
Wirble config
begin
# load wirble
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
rescue LoadError => err
warn "Couldn't load Wirble: #{err}"
end
@scarolan
scarolan / Guardfile
Last active December 28, 2015 06:48
Guardfile for testing a Chef cookbook
# Guardfile for testing this cookbook
guard :rubocop do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
guard :foodcritic, cookbook_paths: '.' do
watch(%r{attributes/.+\.rb$})
watch(%r{providers/.+\.rb$})
watch(%r{recipes/.+\.rb$})
@scarolan
scarolan / bumpy.sh
Created January 14, 2014 20:24
Uses the 'knife spork' plugin and git to accomplish the following: * Bump the cookbook version using "knife spork bump" * Commit changes to git, push to remote repo * Tag the commit with the cookbook version * Upload the cookbook to your chef server
#!/bin/bash
usage="This script should be run from the main directory of your cookbook.\n Usage: $0 cookbookname"
# Did the user supply a cookbook name? Are we in a cookbook directory?
if [ $# -ne 1 ] || [ ! -f metadata.rb ]; then
echo -e $usage; exit 1
fi
cookbook=$1
knife spork bump $cookbook
git add .
@scarolan
scarolan / file.rb
Created February 26, 2014 19:31
Chef Swap File LWRP
use_inline_resources
action :create do
resource_name = new_resource.file_name.gsub('/', '_')
execute "create#{resource_name}" do
command "dd if=/dev/zero of=#{new_resource.file_name} bs=1024 count=#{new_resource.blocks}"
not_if { ::File.exists?(new_resource.file_name) }
notifies :run, "execute[mkswap#{resource_name}]", :immediately
@scarolan
scarolan / default_recipe.rb
Last active August 29, 2015 13:57
Apache Refactoring Bonus Exercise for Chef Fundamentals Training
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
#!/bin/sh
red='\033[1;31m'
green='\033[1;32m'
blue='\033[1;34m'
normal='\033[0m'
bg_white='\033[1;47m'
echo "$green _______________ $normal"
echo "$green / ___/ __/_ __/ $normal"
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ylinux6
driver_config:
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
Fetching 'apache' from source at .
Fetching cookbook index from https://api.berkshelf.com...
←[31m>>>>>> ------Exception-------←[0m
←[31m>>>>>> Class: Kitchen::ActionFailed←[0m
←[31m>>>>>> Message: Failed to complete #converge action: [SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed]←[0m
←[31m>>>>>> ----------------------←[0m
←[31m>>>>>> Please see .kitchen/logs/kitchen.log for more details←[0m
←[31m>>>>>> Also try running `kitchen diagnose --all` for configuration
←[0m
➜ jenkins git:(master) ✗ kitchen init
create .kitchen.yml
run gem install kitchen-vagrant from "."
Fetching: kitchen-vagrant-0.15.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /opt/chefdk/embedded/lib/ruby/gems/2.1.0 directory.