jparker / dotfiles

Home directory content (config files for shells, editors, tools, etc.)

jparker (author)
Thu May 28 17:15:54 -0700 2009
commit  5da063bd97e3b7e1dc253a5004df1016b02a032e
tree    03165d229d6b9b1a17580fd83a69908da598fb61
parent  85f0c54d4a2e6de23d1ca161bd7d636b0ec18328
dotfiles / Capfile
100644 96 lines (78 sloc) 2.361 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
String.class_eval do
  def to_fqdn(domain = '.urgetopunt.com')
    self + domain
  end
end
 
default_run_options[:pty] = true
 
set :gateway, 'shell.speakeasy.net'
 
role :centos, *%w[kotuku hoiho].map {|h| h.to_fqdn }
role :ubuntu, *%w[moa kiwi taiko whio].map {|h| h.to_fqdn }
role :passenger, *%w[moa kiwi taiko whio].map {|h| h.to_fqdn }
 
# TODO: get centos using dotfiles
desc 'Deploy dotfiles'
task :deploy, :roles => [:ubuntu] do
  run 'cd $HOME && git pull'
end
 
namespace :stat do
  desc 'Output kernel version on all servers'
  task :uname, :roles => [:centos, :ubuntu] do
    run 'uname -r'
  end
  
  desc 'Check CPU load on all servers'
  task :uptime, :roles => [:centos, :ubuntu] do
    run 'uptime'
  end
  
  desc 'Check memory usage on all servers'
  task :free, :roles => [:centos, :ubuntu] do
    run '$HOME/bin/memory.sh'
    # run %[free -m | awk '/cache:/ { printf "free: %dmb used: %dmb (%.0f%%)",$4,$3,$3/($3+$4)*100 }']
  end
  
  desc 'Check swap usage on all servers'
  task :swap, :roles => [:centos, :ubuntu] do
    run %[free -m | awk '/Swap:/ { printf "free: %dmb used: %dmb (%.0f%%)",$4,$3,$3/$2*100 }']
  end
  
  desc 'Check root volume usage on all servers'
  task :df, :roles => [:centos, :ubuntu] do
    run 'df -h /'
  end
end
 
namespace :passenger do
  desc 'Get passenger memory stats'
  task :memory, :roles => :passenger do
    sudo '/opt/ruby-enterprise/bin/passenger-memory-stats'
  end
  
  desc 'Get passenger status'
  task :status, :roles => :passenger do
    sudo '/opt/ruby-enterprise/bin/passenger-status'
  end
end
 
namespace :centos do
  desc 'Check for updates on centos servers'
  task :check, :roles => :centos do
    sudo 'yum -d0 check-update'
  end
  
  desc 'Apply updates to centos servers'
  task :upgrade, :roles => :centos do
    sudo 'yum -d0 -y update'
  end
  
  desc 'Clear yum cache on centos servers'
  task :clean, :roles => :centos do
    sudo 'yum clean all'
  end
end
 
namespace :ubuntu do
  desc 'Update apt cache on ubuntu servers'
  task :update, :roles => :ubuntu do
    sudo 'apt-get -qq update'
  end
  
  desc 'Check for updates on ubuntu servers'
  task :check, :roles => :ubuntu do
    ubuntu.update
    sudo 'apt-get -q -s upgrade'
  end
  
  desc 'Apply updates to ubuntu servers'
  task :upgrade, :roles => :ubuntu do
    ubuntu.update
    sudo 'apt-get -qq upgrade'
  end
end