rubber 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGELOG +36 -0
  2. data/VERSION +1 -1
  3. data/generators/vulcanize/templates/base/config/rubber/common/crontab +5 -6
  4. data/generators/vulcanize/templates/base/config/rubber/common/rsyslog.conf +71 -0
  5. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +7 -2
  6. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +4 -12
  7. data/generators/vulcanize/templates/base/script/cron-rake +2 -2
  8. data/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  9. data/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/rubber-complete.yml +38 -0
  10. data/generators/vulcanize/templates/complete_passenger_nginx/templates.rb +8 -0
  11. data/generators/vulcanize/templates/complete_passenger_nginx/templates.yml +8 -0
  12. data/generators/vulcanize/templates/complete_passenger_nginx_mysql/templates.yml +4 -0
  13. data/generators/vulcanize/templates/complete_passenger_nginx_postgresql/templates.yml +4 -0
  14. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +1 -1
  15. data/generators/vulcanize/templates/minimal_passenger_nginx/config/rubber/rubber-complete.yml +37 -0
  16. data/generators/vulcanize/templates/minimal_passenger_nginx/templates.yml +4 -0
  17. data/generators/vulcanize/templates/mongodb/config/rubber/deploy-mongodb.rb +6 -2
  18. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +1 -0
  19. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +2 -1
  20. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +0 -0
  21. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +0 -0
  22. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +1 -1
  23. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +1 -0
  24. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +1 -1
  25. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  26. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  27. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +1 -1
  28. data/generators/vulcanize/templates/passenger_nginx/config/rubber/deploy-passenger_nginx.rb +86 -0
  29. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/application.conf +30 -0
  30. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/crontab +8 -0
  31. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/monit-nginx.conf +7 -0
  32. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-memory.conf +34 -0
  33. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-sudoers.conf +8 -0
  34. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger.conf +47 -0
  35. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx +101 -0
  36. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx.conf +65 -0
  37. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/passenger_nginx.conf +30 -0
  38. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  39. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-index.html +34 -0
  40. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  41. data/generators/vulcanize/templates/passenger_nginx/config/rubber/rubber-passenger_nginx.yml +20 -0
  42. data/generators/vulcanize/templates/passenger_nginx/templates.yml +1 -0
  43. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +51 -49
  44. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +1 -0
  45. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +20 -7
  46. data/generators/vulcanize/templates/postgresql/config/rubber/role/postgresql_slave/recovery.conf +120 -0
  47. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +5 -5
  48. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +6 -1
  49. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +1 -1
  50. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +15 -2
  51. data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +1 -1
  52. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +2 -2
  53. data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +5 -6
  54. data/lib/generators/vulcanize/templates/base/config/rubber/common/rsyslog.conf +71 -0
  55. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +7 -2
  56. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +4 -12
  57. data/lib/generators/vulcanize/templates/base/script/cron-rake +2 -2
  58. data/lib/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  59. data/lib/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/rubber-complete.yml +38 -0
  60. data/lib/generators/vulcanize/templates/complete_passenger_nginx/templates.rb +8 -0
  61. data/lib/generators/vulcanize/templates/complete_passenger_nginx/templates.yml +8 -0
  62. data/lib/generators/vulcanize/templates/complete_passenger_nginx_mysql/templates.yml +4 -0
  63. data/lib/generators/vulcanize/templates/complete_passenger_nginx_postgresql/templates.yml +4 -0
  64. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +1 -1
  65. data/lib/generators/vulcanize/templates/minimal_passenger_nginx/config/rubber/rubber-complete.yml +37 -0
  66. data/lib/generators/vulcanize/templates/minimal_passenger_nginx/templates.yml +4 -0
  67. data/lib/generators/vulcanize/templates/mongodb/config/rubber/deploy-mongodb.rb +6 -2
  68. data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +1 -0
  69. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +2 -1
  70. data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +0 -0
  71. data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +0 -0
  72. data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +1 -1
  73. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +1 -0
  74. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +1 -1
  75. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  76. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  77. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +1 -1
  78. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/deploy-passenger_nginx.rb +86 -0
  79. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/application.conf +30 -0
  80. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/crontab +8 -0
  81. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/monit-nginx.conf +7 -0
  82. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-memory.conf +34 -0
  83. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-sudoers.conf +8 -0
  84. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger.conf +47 -0
  85. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx +101 -0
  86. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx.conf +65 -0
  87. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/passenger_nginx.conf +30 -0
  88. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  89. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-index.html +34 -0
  90. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  91. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/rubber-passenger_nginx.yml +20 -0
  92. data/lib/generators/vulcanize/templates/passenger_nginx/templates.yml +1 -0
  93. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +51 -49
  94. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +1 -0
  95. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +20 -7
  96. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/postgresql_slave/recovery.conf +120 -0
  97. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +5 -5
  98. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +6 -1
  99. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +1 -1
  100. data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +15 -2
  101. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +1 -1
  102. data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +2 -2
  103. data/lib/rubber/dns/zerigo.rb +1 -1
  104. data/lib/rubber/recipes/rubber/setup.rb +1 -1
  105. data/lib/rubber/recipes/rubber/volumes.rb +3 -3
  106. metadata +55 -5
@@ -0,0 +1,34 @@
1
+ <%
2
+ @path = "/var/www/index.html"
3
+ %>
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
5
+ <html>
6
+ <head>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
+ <title>Rubber Admin Tools</title>
9
+ </head>
10
+ <body>
11
+ <h1>Rubber Admin Tools</h1>
12
+ <ul>
13
+
14
+ <li><a href="/munin/">Munin</a></li>
15
+
16
+ <% if cruise_host = rubber_instances.for_role('cruise').first %>
17
+ <li><a href="http://<%= cruise_host %>/cruise/">CruiseControl</a></li>
18
+ <% end %>
19
+
20
+ <% rubber_instances.for_role('haproxy').sort {|a,b| a.name <=> b.name }.each do |ic| %>
21
+ <li><a href="/haproxy_<%= ic.name %>/">HAProxy <%= ic.name %></a></li>
22
+ <% end %>
23
+
24
+ <% rubber_instances.sort {|a,b| a.name <=> b.name }.each do |ic| %>
25
+ <li><a href="/monit_<%= ic.name %>/">Monit <%= ic.name %></a></li>
26
+ <% end %>
27
+
28
+ <% if resque_host = rubber_instances.for_role('resque_web').first %>
29
+ <li><a href="/resque/">Resque</a></li>
30
+ <% end %>
31
+
32
+ </ul>
33
+ </body>
34
+ </html>
@@ -0,0 +1,7 @@
1
+ <%
2
+ @path = "#{RUBBER_ROOT}/config/#{rubber_env.app_name}.auth"
3
+ user = rubber_env.web_tools_user || 'admin'
4
+ pass = rubber_env.web_tools_password || rand(1000000000).to_s
5
+ %>
6
+
7
+ <%= user %>:<%= pass.crypt(sprintf('%02d', rand(100)))%>
@@ -0,0 +1,20 @@
1
+ passenger_version: 3.0.7
2
+ nginx_version: 1.0.0
3
+ passenger_root: "#{rvm_gem_home}/gems/passenger-#{passenger_version}"
4
+ passenger_ruby: "#{rvm_prefix}/wrappers/#{`bash -l -c 'rvm strings #{rvm_ruby}'`.strip}/ruby"
5
+ passenger_lib: "#{passenger_root}/ext/nginx"
6
+ passenger_listen_port: 7000
7
+ passenger_listen_ssl_port: 7001
8
+ max_app_connections: 20
9
+
10
+ use_ssl_key: false
11
+ #if you use an ssl key, put your cert and key
12
+ # in
13
+ # #{RUBBER_ROOT}/config/#{rubber_env.domain} .crt and .key
14
+ #otherwise defaults to key included with linux
15
+
16
+
17
+ roles:
18
+ passenger_nginx:
19
+ packages: [libcurl4-openssl-dev]
20
+ gems: [[passenger, "#{passenger_version}"]]
@@ -0,0 +1 @@
1
+ description: Phusion Passenger module (Nginx)
@@ -1,16 +1,16 @@
1
1
 
2
2
  namespace :rubber do
3
-
3
+
4
4
  namespace :postgresql do
5
-
5
+
6
6
  rubber.allow_optional_tasks(self)
7
7
 
8
8
  before "rubber:install_packages", "rubber:postgresql:setup_apt_sources"
9
9
 
10
- task :setup_apt_sources, :roles => [:postgresql_master, :postgresql_save] do
10
+ task :setup_apt_sources do
11
11
  rsudo "add-apt-repository ppa:pitti/postgresql"
12
12
  end
13
-
13
+
14
14
  after "rubber:create", "rubber:postgresql:validate_db_roles"
15
15
 
16
16
  task :validate_db_roles do
@@ -23,17 +23,17 @@ namespace :rubber do
23
23
  end
24
24
 
25
25
  after "rubber:bootstrap", "rubber:postgresql:bootstrap"
26
-
27
-
26
+
27
+
28
28
  # Bootstrap the production database config. Db bootstrap is special - the
29
29
  # user could be requiring the rails env inside some of their config
30
30
  # templates, which creates a catch 22 situation with the db, so we try and
31
31
  # bootstrap the db separate from the rest of the config
32
32
  task :bootstrap, :roles => [:postgresql_master, :postgresql_slave] do
33
-
33
+
34
34
  # Conditionally bootstrap for each node/role only if that node has not
35
35
  # been boostrapped for that role before
36
- master_instances = rubber_instances.for_role("postgresql_master") & rubber_instances.filtered
36
+ master_instances = rubber_instances.for_role("postgresql_master") & rubber_instances.filtered
37
37
  master_instances.each do |ic|
38
38
  task_name = "_bootstrap_postgresql_master_#{ic.full_name}".to_sym()
39
39
  task task_name, :hosts => ic.full_name do
@@ -41,49 +41,55 @@ namespace :rubber do
41
41
  exists = capture("echo $(ls #{env.postgresql_data_dir}/ 2> /dev/null)")
42
42
  if exists.strip.size == 0
43
43
  common_bootstrap("postgresql_master")
44
+ sudo "/usr/lib/postgresql/#{rubber_env.postgresql_ver}/bin/initdb -D #{rubber_env.postgresql_data_dir}", :as => 'postgres'
45
+ sudo "#{rubber_env.postgresql_ctl} start"
46
+ sleep 5
44
47
 
45
48
  create_user_cmd = "CREATE USER #{env.db_user} WITH NOSUPERUSER CREATEDB NOCREATEROLE"
46
- create_user_cmd << " PASSWORD '#{env.db_pass}'" if env.db_pass
49
+ create_user_cmd << "PASSWORD '#{env.db_pass}'" if env.db_pass
47
50
  rubber.sudo_script "create_master_db", <<-ENDSCRIPT
48
51
  sudo -u postgres psql -c "#{create_user_cmd}"
49
52
  sudo -u postgres psql -c "CREATE DATABASE #{env.db_name} WITH OWNER #{env.db_user}"
53
+ sudo -u postgres createlang plpythonu #{env.db_name}
50
54
  ENDSCRIPT
51
55
  end
52
56
  end
53
57
  send task_name
54
58
  end
55
59
 
56
- # Wait for postgresql 9.0 to be available before allowing slaves
57
- #
58
- # slave_instances = rubber_instances.for_role("postgresql_slave") & rubber_instances.filtered
59
- # slave_instances.each do |ic|
60
- # task_name = "_bootstrap_postgresql_slave_#{ic.full_name}".to_sym()
61
- # task task_name, :hosts => ic.full_name do
62
- # env = rubber_cfg.environment.bind("postgresql_slave", ic.name)
63
- # exists = capture("echo $(ls #{env.db_data_dir}/ 2> /dev/null)")
64
- # if exists.strip.size == 0
65
- # common_bootstrap("postgresql_slave")
66
- #
67
- # source = master = rubber_instances.for_role("postgresql_master").first
68
- #
69
- # slave_pub_key = capture("cat /root/.ssh/id_dsa.pub")
70
- # sudo "echo \"#{slave_pub_key}\" >> /root/.ssh/authorized_keys", :hosts => [master.full_name]
71
- #
72
- # base_backup_script = <<-ENDSCRIPT
73
- # sudo -u postgres psql -c "SELECT pg_start_backup('rubber_create_slave')"
74
- # tar --exclude pg_xlog -czf /tmp/postgresql-data.tgz #{env.postgresql_data_dir}
75
- # tar -czf /tmp/postgresql-archive.tgz #{env.postgresql_archive_dir}
76
- # sudo -u postgres psql -c "SELECT pg_stop_backup()"
77
- # ENDSCRIPT
78
- #
79
- # rubber.sudo_script "create_slave_db_from_master", base_backup_script, :hosts => [master.full_name]
80
- #
81
- # rsudo "psql -u root -e \"start slave;\""
82
- # end
83
- # end
84
- # send task_name
85
- # end
60
+ slave_instances = rubber_instances.for_role("postgresql_slave") & rubber_instances.filtered
61
+ slave_instances.each do |ic|
62
+ task_name = "_bootstrap_postgresql_slave_#{ic.full_name}".to_sym()
63
+ task task_name, :hosts => ic.full_name do
64
+ env = rubber_cfg.environment.bind("postgresql_slave", ic.name)
65
+ exists = capture("echo $(ls #{env.postgresql_data_dir}/ 2> /dev/null)")
66
+ if exists.strip.size == 0
67
+ common_bootstrap("postgresql_slave")
68
+
69
+ source = master = rubber_instances.for_role("postgresql_master").first
70
+
71
+ slave_pub_key = capture("cat /root/.ssh/id_dsa.pub")
72
+ sudo "echo \"#{slave_pub_key}\" >> /root/.ssh/authorized_keys", :hosts => [master.full_name]
73
+
74
+ base_backup_script = <<-ENDSCRIPT
75
+ sudo -u postgres psql -c "SELECT pg_start_backup('rubber_create_slave')";
76
+ rsync -a #{env.postgresql_data_dir}/* #{ic.full_name}:#{env.postgresql_data_dir}/ --exclude postmaster.pid --exclude recovery.* --exclude trigger_file;
77
+ sudo -u postgres psql -c "SELECT pg_stop_backup()"
78
+ ENDSCRIPT
79
+
80
+ sudo base_backup_script, :hosts => [master.full_name]
86
81
 
82
+ # Gen just the slave-specific conf.
83
+ rubber.run_config(:RUBBER_ENV => RUBBER_ENV, :FILE => "role/postgresql_slave/", :FORCE => true, :deploy_path => release_path)
84
+
85
+ # Start up the server.
86
+ sudo "#{rubber_env.postgresql_ctl} start"
87
+ sleep 5
88
+ end
89
+ end
90
+
91
+ send task_name
92
+ end
87
93
  end
88
94
 
89
95
  after "rubber:munin:custom_install", "rubber:postgresql:install_munin_plugins"
@@ -106,12 +112,12 @@ namespace :rubber do
106
112
  #{commands.join(';')}
107
113
  ENDSCRIPT
108
114
  end
109
-
115
+
110
116
  # TODO: Make the setup/update happen just once per host
111
117
  def common_bootstrap(role)
112
118
  # postgresql package install starts postgresql, so stop it
113
119
  rsudo "#{rubber_env.postgresql_ctl} stop" rescue nil
114
-
120
+
115
121
  # After everything installed on machines, we need the source tree
116
122
  # on hosts in order to run rubber:config for bootstrapping the db
117
123
  rubber.update_code_for_bootstrap
@@ -124,28 +130,24 @@ namespace :rubber do
124
130
  sudo_script 'reconfigure-postgresql', <<-ENDSCRIPT
125
131
  mkdir -p #{dirs.join(' ')}
126
132
  chown -R postgres:postgres #{dirs.join(' ')}
127
-
128
- sudo -u postgres /usr/lib/postgresql/#{rubber_env.postgresql_ver}/bin/initdb -D #{rubber_env.postgresql_data_dir}
129
-
130
- #{rubber_env.postgresql_ctl} start
133
+ chmod 700 #{rubber_env.postgresql_data_dir}
131
134
  ENDSCRIPT
132
- sleep 5
133
135
  end
134
-
136
+
135
137
  desc <<-DESC
136
138
  Starts the postgresql daemons
137
139
  DESC
138
140
  task :start, :roles => [:postgresql_master, :postgresql_slave] do
139
141
  rsudo "#{rubber_env.postgresql_ctl} start"
140
142
  end
141
-
143
+
142
144
  desc <<-DESC
143
145
  Stops the postgresql daemons
144
146
  DESC
145
147
  task :stop, :roles => [:postgresql_master, :postgresql_slave] do
146
148
  rsudo "#{rubber_env.postgresql_ctl} stop"
147
149
  end
148
-
150
+
149
151
  desc <<-DESC
150
152
  Restarts the postgresql daemons
151
153
  DESC
@@ -86,4 +86,5 @@ local all postgres ident
86
86
  local all <%= rubber_env.db_user %> <%= scheme %>
87
87
  host all all 127.0.0.1/32 <%= scheme %>
88
88
  host all all ::1/128 <%= scheme %>
89
+ host replication postgres 10.0.0.1/8 <%= scheme %>
89
90
  host all <%= rubber_env.db_user %> 10.0.0.1/8 <%= scheme %>
@@ -109,7 +109,7 @@ unix_socket_directory = '/var/run/postgresql' # (change requires restart)
109
109
 
110
110
  # - Memory -
111
111
 
112
- shared_buffers = 28MB # min 128kB
112
+ shared_buffers = 384MB # min 128kB
113
113
  # (change requires restart)
114
114
  #temp_buffers = 8MB # min 800kB
115
115
  #max_prepared_transactions = 0 # zero disables the feature
@@ -153,7 +153,7 @@ shared_buffers = 28MB # min 128kB
153
153
 
154
154
  # - Settings -
155
155
 
156
- #wal_level = minimal # minimal, archive, or hot_standby
156
+ wal_level = hot_standby # minimal, archive, or hot_standby
157
157
  # (change requires restart)
158
158
  #fsync = on # turns forced synchronization on or off
159
159
  #synchronous_commit = on # immediate fsync at commit
@@ -187,24 +187,37 @@ shared_buffers = 28MB # min 128kB
187
187
  #archive_timeout = 0 # force a logfile segment switch after this
188
188
  # number of seconds; 0 disables
189
189
 
190
+ <%- if rubber_instances[rubber_env.host].role_names.include?('postgresql_master') %>
190
191
  # - Streaming Replication -
191
192
 
192
- #max_wal_senders = 0 # max number of walsender processes
193
+ # Set the maximum number of concurrent connections from the standby servers.
194
+ max_wal_senders = 5 # max number of walsender processes
193
195
  # (change requires restart)
194
196
  #wal_sender_delay = 200ms # walsender cycle time, 1-10000 milliseconds
195
- #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables
197
+
198
+ # To prevent the primary server from removing the WAL segments required for
199
+ # the standby server before shipping them, set the minimum number of segments
200
+ # retained in the pg_xlog directory. At least wal_keep_segments should be
201
+ # larger than the number of segments generated between the beginning of
202
+ # online-backup and the startup of streaming replication. If you enable WAL
203
+ # archiving to an archive directory accessible from the standby, this may
204
+ # not be necessary.
205
+ wal_keep_segments = 128 # in logfile segments, 16MB each -- 128 = 2GB; 0 disables
196
206
  #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
207
+ <%- end %>
197
208
 
209
+ <%- if rubber_instances[rubber_env.host].role_names.include?('postgresql_slave') %>
198
210
  # - Standby Servers -
199
211
 
200
- #hot_standby = off # "on" allows queries during recovery
212
+ hot_standby = on # "on" allows queries during recovery
201
213
  # (change requires restart)
202
214
  #max_standby_archive_delay = 30s # max delay before canceling queries
203
215
  # when reading WAL from archive;
204
216
  # -1 allows indefinite delay
205
- #max_standby_streaming_delay = 30s # max delay before canceling queries
217
+ max_standby_streaming_delay = 30min # max delay before canceling queries
206
218
  # when reading streaming WAL;
207
219
  # -1 allows indefinite delay
220
+ <%- end %>
208
221
 
209
222
 
210
223
  #------------------------------------------------------------------------------
@@ -340,7 +353,7 @@ shared_buffers = 28MB # min 128kB
340
353
  # fatal
341
354
  # panic (effectively off)
342
355
 
343
- log_min_duration_statement = 1 # -1 is disabled, 0 logs all statements
356
+ log_min_duration_statement = 200 # -1 is disabled, 0 logs all statements
344
357
  # and their durations, > 0 logs only
345
358
  # statements running at least this number
346
359
  # of milliseconds
@@ -0,0 +1,120 @@
1
+ <%-
2
+ @path = "#{rubber_env.postgresql_data_dir}/recovery.conf"
3
+ %>
4
+ # -------------------------------
5
+ # PostgreSQL recovery config file
6
+ # -------------------------------
7
+ #
8
+ # Edit this file to provide the parameters that PostgreSQL needs to
9
+ # perform an archive recovery of a database, or to act as a log-streaming
10
+ # replication standby.
11
+ #
12
+ # If "recovery.conf" is present in the PostgreSQL data directory, it is
13
+ # read on postmaster startup. After successful recovery, it is renamed
14
+ # to "recovery.done" to ensure that we do not accidentally re-enter
15
+ # archive recovery or standby mode.
16
+ #
17
+ # This file consists of lines of the form:
18
+ #
19
+ # name = 'value'
20
+ #
21
+ # (The quotes around the value are NOT optional, but the "=" is.)
22
+ #
23
+ # Comments are introduced with '#'.
24
+ #
25
+ # The complete list of option names and allowed values can be found
26
+ # in the PostgreSQL documentation.
27
+ #
28
+ #---------------------------------------------------------------------------
29
+ # ARCHIVE RECOVERY PARAMETERS
30
+ #---------------------------------------------------------------------------
31
+ #
32
+ # restore_command
33
+ #
34
+ # specifies the shell command that is executed to copy log files
35
+ # back from archival storage. The command string may contain %f,
36
+ # which is replaced by the name of the desired log file, and %p,
37
+ # which is replaced by the absolute path to copy the log file to.
38
+ #
39
+ # This parameter is *required* for an archive recovery, but optional
40
+ # for streaming replication.
41
+ #
42
+ # It is important that the command return nonzero exit status on failure.
43
+ # The command *will* be asked for log files that are not present in the
44
+ # archive; it must return nonzero when so asked.
45
+ #
46
+ # NOTE that the basename of %p will be different from %f; do not
47
+ # expect them to be interchangeable.
48
+ #
49
+ #restore_command = '' # e.g. 'cp /mnt/server/archivedir/%f %p'
50
+ #
51
+ #
52
+ # archive_cleanup_command
53
+ #
54
+ # specifies an optional shell command to execute at every restartpoint.
55
+ # This can be useful for cleaning up the archive of a standby server.
56
+ #
57
+ #archive_cleanup_command = ''
58
+ #
59
+ # recovery_end_command
60
+ #
61
+ # specifies an optional shell command to execute at completion of recovery.
62
+ # This can be useful for cleaning up after the restore_command.
63
+ #
64
+ #recovery_end_command = ''
65
+ #
66
+ #---------------------------------------------------------------------------
67
+ # RECOVERY TARGET PARAMETERS
68
+ #---------------------------------------------------------------------------
69
+ #
70
+ # By default, recovery will rollforward to the end of the WAL log.
71
+ # If you want to stop rollforward at a specific point, you
72
+ # must set a recovery target.
73
+ #
74
+ # You may set a recovery target either by transactionId, or
75
+ # by timestamp. Recovery may either include or exclude the
76
+ # transaction(s) with the recovery target value (ie, stop either
77
+ # just after or just before the given target, respectively).
78
+ #
79
+ #recovery_target_time = '' # e.g. '2004-07-14 22:39:00 EST'
80
+ #
81
+ #recovery_target_xid = ''
82
+ #
83
+ #recovery_target_inclusive = 'true'
84
+ #
85
+ #
86
+ # If you want to recover into a timeline other than the "main line" shown in
87
+ # pg_control, specify the timeline number here, or write 'latest' to get
88
+ # the latest branch for which there's a history file.
89
+ #
90
+ #recovery_target_timeline = 'latest'
91
+ #
92
+ #---------------------------------------------------------------------------
93
+ # STANDBY SERVER PARAMETERS
94
+ #---------------------------------------------------------------------------
95
+ #
96
+ # When standby_mode is enabled, the PostgreSQL server will work as
97
+ # a standby. It tries to connect to the primary according to the
98
+ # connection settings primary_conninfo, and receives XLOG records
99
+ # continuously.
100
+ #
101
+ standby_mode = 'on'
102
+ #
103
+ primary_conninfo = 'host=<%= rubber_instances.for_role('postgresql_master').first.name %> port=5432 user=postgres' # e.g. 'host=localhost port=5432'
104
+ #
105
+ #
106
+ # By default, a standby server keeps streaming XLOG records from the
107
+ # primary indefinitely. If you want to stop streaming and finish recovery,
108
+ # opening up the system in read/write mode, specify path to a trigger file.
109
+ # Server will poll the trigger file path periodically and stop streaming
110
+ # when it's found.
111
+ #
112
+ trigger_file = '<%= rubber_env.postgresql_data_dir %>/trigger_file'
113
+ #
114
+ #---------------------------------------------------------------------------
115
+ # HOT STANDBY PARAMETERS
116
+ #---------------------------------------------------------------------------
117
+ #
118
+ # Hot Standby related parameters are listed in postgresql.conf
119
+ #
120
+ #---------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
 
2
- # REQUIRED: The credentials for creating/accessong your app's database
2
+ # REQUIRED: The credentials for creating/accessing your app's database
3
3
  #
4
4
  db_user: "#{app_name[0,16]}"
5
5
  db_pass:
@@ -16,19 +16,19 @@ db_backup_cmd: "nice sudo -u postgres pg_dumpall -U postgres | gzip -c > %backup
16
16
  # "rake rubber:restore_db_s3"
17
17
  # This command will receive the data generated by db_backup_cmd via
18
18
  # its standard input
19
- db_restore_cmd: "zcat - | psql -Uroot -h %host% %name%"
19
+ db_restore_cmd: "zcat - | psql -U postgres -h %host% %name%"
20
20
 
21
21
  postgresql_ver: 9.0
22
22
  postgresql_conf_dir: "/etc/postgresql/#{postgresql_ver}/main"
23
- postgresql_data_dir: /mnt/postgresql/data
24
- postgresql_archive_dir: /mnt/postgresql/archive
23
+ postgresql_data_dir: "/mnt/postgresql/#{postgresql_ver}/data"
24
+ postgresql_archive_dir: "/mnt/postgresql/#{postgresql_ver}/archive"
25
25
  postgresql_pid_file: "/var/run/postgresql/#{postgresql_ver}-main.pid"
26
26
  postgresql_ctl: "/usr/bin/env service postgresql"
27
27
 
28
28
  # Capistrano needs db:primary role for migrate to work,
29
29
  # so we might as well just make consistent across the board
30
30
  role_dependencies:
31
- postgresql_master: [db:primary=true]
31
+ postgresql_master: ["db:primary=true"]
32
32
  postgresql_slave: [db]
33
33
  db:primary=true: [postgresql_master]
34
34
  db: [postgresql_slave]