Skip to content

Instantly share code, notes, and snippets.

View johnfitzpatrick's full-sized avatar

John Fitzpatrick johnfitzpatrick

  • Kong
  • Belfast, Northern Ireland
View GitHub Profile
#
# Cookbook Name:: myapache
# Recipe:: default
#
# Copyright (c) 2014 The Authors, All Rights Reserved.
#
package "httpd"
execute "mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled" do
only_if do
ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule prefork.c>
StartServers 8
node.default['haproxy']['members'] = [{
"hostname" => "localhost",
"ipaddress" => "127.0.0.1",
"port" => node["myapache"]["port"],
"ssl_port" => node["myapache"]["port"]
}]
node.default['haproxy']['admin']['address_bind'] = "0.0.0.0"
node.default['haproxy']['admin']['port'] = 8082
node.default['haproxy']['enable_stats_socket'] = true
@johnfitzpatrick
johnfitzpatrick / myapache_receipes_default.rb
Created December 10, 2014 10:12
myapache_receipes_default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
@johnfitzpatrick
johnfitzpatrick / cookbooks_mailx_spec_unit_default_spec.rb
Created July 25, 2014 11:01
cookbooks_mailx_spec_unit_default_spec.rb
require 'spec_helper'
describe 'mailx::default' do
context 'on Debian' do
let(:chef_run) { ChefSpec::Runner.new({:platform => 'ubuntu', :version => '14.04'}).converge(described_recipe) }
it 'should install the correct packages' do
expect(chef_run).to install_package 'mailutils'
end
end
@johnfitzpatrick
johnfitzpatrick / cookbooks_apache_recipes_default.rb
Last active August 29, 2015 14:01
Intermediate class cookbooks/apache/recipes/default.rb
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
@johnfitzpatrick
johnfitzpatrick / cookbooks_apache_providers_vhost.rb
Created May 21, 2014 09:37
cookbooks/apache/providers/vhost.rb
use_inline_resources
action :create do
# Set the document root
document_root = "/srv/apache/#{new_resource.site_name}"
# Add a template for Apache virtual host configuration
template "/etc/httpd/conf.d/#{new_resource.site_name}.conf" do
source "custom.erb"
mode "0644"
require 'rubygems'
require 'pony'
module MyCompany
class EmailMe < Chef::Handler
def initialize(from_address, to_address)
@from_address = from_address
@to_address = to_address
end
@johnfitzpatrick
johnfitzpatrick / cookbooks_email_handler_recipes_default.rb
Last active August 29, 2015 14:01
Handler recipe for Chef Intermediate class
chef_gem "pony" do
action :install
end
include_recipe "chef_handler"
cookbook_file "#{node['chef_handler']['handler_path']}/email_handler.rb" do
source "handlers/email_handler.rb"
owner "root"
group "root"
@johnfitzpatrick
johnfitzpatrick / apache_files_default_plugins_modules.rb
Created May 14, 2014 10:16
Ohai module refactor in Chef Intermediate class
Ohai.plugin(:Apache) do
provides "apache/modules"
collect_data(:default) do
apache Mash.new
apache[:modules] = {:static => [], :shared => []}
modules = shell_out("apachectl -t -D DUMP_MODULES")
modules.stdout.each_line do |line|
fullkey, value = line.split(/\(/, 2).map {|i| i.strip}
apache_mod = fullkey.gsub(/_module/,"")