This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################ | |
##### script to backup lucene index from elastic search #### | |
################################################################ | |
# Shamelessly copied from https://gist.github.com/nherment/1939828 | |
NOW=`date +%Y%m%d%H%M%S` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && " + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "create read-only user and set access to #{db_name} database" | |
task :create_ro_user, :roles => :dbmaster do | |
# General select-only access to all tables in #{db_name} | |
stmt = <<-SQL | |
GRANT SELECT ON #{db_name}.* TO #{rouser}@'%' IDENTIFIED BY '#{ropw}'; | |
SQL | |
run "mysql -u#{dbmasterroot} -p#{dbmasterrootpw} -e \"#{stmt}\"" | |
# Look up tables to which rw grants apply |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Configure Varnish cache module" | |
task :varnish, :roles => :publish do | |
run "cd #{latest_release}/docroot/sites/exacttarget ; drush dl -y varnish" | |
run "cd #{latest_release}/docroot/sites/exacttarget ; drush en -y varnish" | |
vcache = (find_servers :roles => :varnish).collect { |s| "#{s}:6080" }.join " " | |
vsettings = { "varnish_cache_clear" => "1", | |
"varnish_control_key" => :varnish_key.to_s, | |
"varnish_control_terminal" => "#{vcache}", | |
"varnish_flush_cron" => "0", | |
"varnish_socket_timeout" => "3600", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Retrieve all nodes' local hostnames and set the master_ip | |
# based on a match to *this* node's local hostname. | |
# | |
# I don't know why this is even necessary. | |
redis_nodes = all_provider_local_hostnames(node[:redis][:service_name]) | |
master_ip = "" | |
myhostname = node[:cloud][:local_hostname] rescue node[:fqdn] | |
found = 0 | |
redis_sorted_nodes = redis_nodes.sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :varnish do | |
desc "Configure varnish" | |
task :configure, :roles => :varnish do | |
upload("config/deploy/#{stage}/backends.vcl", "/tmp", :via => :scp) | |
run "#{sudo} cp /tmp/backends.vcl /etc/varnish" | |
run "#{sudo} varnishadm vcl.load #{date} /etc/varnish/default.vcl && " + | |
"#{sudo} varnishadm vcl.use #{date} /etc/varnish/default.vcl" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true ; do | |
for i in {1..4} ; do | |
now=$(date '+%s' | perl -pe 's/\012//') | |
c=$(echo stats | nc xtincache0$i.xt.local 11211 | grep curr_conn | cut -d ' ' -f 3 | perl -pe 's/\015//' ) | |
echo "greg.cache.xtincache0${i}.curr_connections ${c} $now" | nc graphite-s1.xt.local 2013 | |
done | |
sleep 5 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actions :create | |
attribute :user, :kind_of => String, :name_attribute => true, :required => true | |
attribute :type, :kind_of => String, :default => "rsa", :equal_to => ["rsa", "dsa"] | |
attribute :length, :kind_of => String, :default => "2048", :equal_to => [ "1024", "2048", "4096" ] | |
action :create do | |
gem_package "sshkey" do | |
action :install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :pre_deploy do | |
task "default" do | |
create_zipfile | |
end | |
desc "Create package zip file" | |
task "create_zipfile" do | |
run_locally "mkdir -p #{build_dir}" | |
run_locally "git archive --format=zip --prefix=#{app_name}/ -6 --output=#{build_dir}/#{app_name}-`git rev-parse --short=8 HEAD`.zip HEAD" |
NewerOlder