Skip to content

Instantly share code, notes, and snippets.

View hemalvarambhia's full-sized avatar
👨‍🔬

Hemal Varambhia hemalvarambhia

👨‍🔬
View GitHub Profile
@hemalvarambhia
hemalvarambhia / nginx_matcher.rb
Last active August 29, 2015 14:08
The nginx Rspec matcher for serverspec
module NginxMatchers
RSpec::Matchers.define :permit do |ip_addresses|
match do |content|
escaped_url = Regexp.escape @url
ip_addresses.all?{ |ip_address|
content=~/location #{escaped_url} \{[^}]+allow #{ip_address};/m
}
end
chain :access_to do |url|
@hemalvarambhia
hemalvarambhia / app.rb
Created November 6, 2014 07:46
One of the recipes in the legacy chef repo shown at the November London Chef Users Meetup.
# Determine which apps require the 'app' tier to be set up on this node:
tier_apps = ai_stack.apps_for_tier(node, 'app')
# Initialize an array to store user names that will later be added to the
# "sshlogin" group:
sshlogin_users = []
# Perform configuration required by all apps:
unless tier_apps.empty?
# Ensure all dependencies necessary to build Ruby are present:
@hemalvarambhia
hemalvarambhia / default.rb
Created November 5, 2014 10:29
The refactored cookbook shown at the November London Chef Users Meetup. The declarations here are Chef definitions that grew out of the refactoring process.
#
# Cookbook Name:: rails_app
# Recipe:: default
#
# Copyright 2014, AbelsonInfo
#
# All rights reserved - Do Not Redistribute
#
include_recipe 'rails_app_server::default'