Skip to content

Instantly share code, notes, and snippets.

@ctgswallow
Created March 5, 2013 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctgswallow/5092172 to your computer and use it in GitHub Desktop.
Save ctgswallow/5092172 to your computer and use it in GitHub Desktop.
vmods
#
# Cookbook Name:: varnish
# Recipe:: graphite-vmods
#
# Copyright 2013, ExactTarget
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Quick and dirty install the statsd vmod
# Maybe this should become a provider for varnish.
tmp = Chef::Config[:file_cache_path]
version = "#{node[:varnish][:version]}.#{node[:varnish][:minor]}"
package "automake"
package "libtool"
package "libpcre3-dev"
package "python-docutils"
git "#{tmp}/libvmod-statsd" do
repository "https://github.com/jib/libvmod-statsd"
reference "master"
revision node[:varnish][:libvmod_statsd_version]
action :checkout
end
git "#{tmp}/libvmod-timers" do
repository "https://github.com/jib/libvmod-timers.git"
reference "master"
revision node[:varnish][:libvmod_timers_version]
action :checkout
end
remote_file "#{tmp}/varnish-cache-#{version}.tar.gz" do
source "http://repo.varnish-cache.org/source/varnish-#{version}.tar.gz"
action :create_if_missing
end
execute "extract varnish source" do
command "tar xzf varnish-cache-#{version}.tar.gz"
cwd tmp
creates "#{tmp}/varnish-#{version}"
end
execute "configure / compile varnish source" do
# srsly wtf.
command "./configure && make"
cwd "#{tmp}/varnish-#{version}"
creates "#{tmp}/varnish-#{version}/bin/varnishtest/varnishtest"
end
%w[timers statsd].each do |vmod|
execute "autogen libvmod-#{vmod}" do
command "./autogen.sh"
cwd "#{tmp}/libvmod-#{vmod}"
creates "#{tmp}/libvmod-#{vmod}/configure"
end
execute "configure / compile libvmod-#{vmod}" do
command "./configure VARNISHSRC=#{tmp}/varnish-#{version} VMODDIR=/usr/lib/varnish/vmods && make"
cwd "#{tmp}/libvmod-#{vmod}"
creates "#{tmp}/libvmod-#{vmod}/src/.libs/libvmod-#{vmod}.so"
end
execute "install libvmod-#{vmod}" do
command "make install"
cwd "#{tmp}/libvmod-#{vmod}"
creates "/usr/lib/varnish/vmods/libvmod-#{vmod}.so"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment