Skip to content

Instantly share code, notes, and snippets.

@ctgswallow
Last active December 14, 2015 13:48
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/5095878 to your computer and use it in GitHub Desktop.
Save ctgswallow/5095878 to your computer and use it in GitHub Desktop.
Varnish config from template
namespace :varnish do
desc "Configure varnish"
task :configure, :roles => :varnish do
ws = find_servers :roles => :web
set :ws, ws
backends_vcl = from_template("backends.vcl.erb")
put backends_vcl, "/tmp/backends.vcl"
run "sed -i -e 's/SUFFIX/'`hostname -s`'/' /tmp/backends.vcl"
run "#{sudo} cp /tmp/backends.vcl /etc/varnish"
run "#{sudo} varnishadm vcl.load #{date} /etc/varnish/default.vcl && " +
"#{sudo} varnishadm vcl.use #{date}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment