postgresinator 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  set :postgres_templates_path, "templates/postgres"
2
2
  set :postgres_config_files, ["postgresql.conf", "pg_hba.conf"]
3
3
  set :postgres_recovery_conf, ["recovery.conf"]
4
- set :postgres_root_path, -> { shared_path.join('postgres') }
4
+ set :postgres_root_path, -> { shared_path.join('postgres', fetch(:stage).to_s) }
5
5
  set :postgres_data_path, -> { fetch(:postgres_root_path).join('data') }
6
6
  set :postgres_config_path, -> { fetch(:postgres_root_path).join('conf') }
7
7
  set :postgres_socket_path, -> { fetch(:postgres_root_path).join('run') }
@@ -9,75 +9,87 @@ set :postgres_recovery_conf, -> { "#{fetch(:postgres_data_path)}/reco
9
9
  set :postgres_ssl_key, -> { "#{fetch(:postgres_data_path)}/server.key" }
10
10
  set :postgres_ssl_csr, -> { "#{fetch(:postgres_data_path)}/server.csr" }
11
11
  set :postgres_ssl_crt, -> { "#{fetch(:postgres_data_path)}/server.crt" }
12
- set :postgres_log_level, "info"
12
+ set :postgres_entrypoint, -> { "/usr/lib/postgresql/#{fetch(:postgres_version)}/bin/postgres" }
13
+ set :postgres_main_dir, -> { "/var/lib/postgresql/#{fetch(:postgres_version)}/main/" }
13
14
 
14
15
  def pg_run(host)
15
- execute("docker", "run", "--detach", "--tty", "--user", "postgres",
16
+ execute(
17
+ "docker", "run", "--detach", "--tty", "--user", "postgres",
16
18
  "--name", host.properties.postgres_container_name,
17
19
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
18
- "--expose", "5432",
20
+ "--expose", 5432,
19
21
  "--publish", "0.0.0.0:#{host.properties.postgres_port}:5432",
20
22
  "--restart", "always",
21
- "--entrypoint", "/usr/lib/postgresql/9.1/bin/postgres",
23
+ # TODO switch to universal entrypoints instead of version specific ones
24
+ "--entrypoint", fetch(:postgres_entrypoint),
22
25
  fetch(:postgres_image_name),
23
- "-D", shared_path.join('postgres', 'data'),
24
- "-c", "config_file=#{shared_path.join('postgres', 'conf', 'postgresql.conf')}")
26
+ "-D", fetch(:postgres_data_path),
27
+ "-c", "config_file=#{fetch(:postgres_config_path)}/postgresql.conf"
28
+ )
25
29
  end
26
30
  def pg_init(host)
27
- execute("docker", "run", "--rm", "--user", "root",
31
+ execute(
32
+ "docker", "run", "--rm", "--user", "root",
28
33
  "--volume", "#{fetch(:postgres_data_path)}:/postgresql-data:rw",
29
34
  "--entrypoint", "/usr/bin/rsync",
30
- fetch(:postgres_image_name), "-ah", "/var/lib/postgresql/9.1/main/", "/postgresql-data/")
35
+ fetch(:postgres_image_name), "-ah", fetch(:postgres_main_dir), "/postgresql-data/"
36
+ )
31
37
  end
32
38
  def pg_replicate(host)
33
- execute("docker", "run", "--rm", "--user", "postgres",
39
+ execute(
40
+ "docker", "run", "--rm", "--user", "postgres",
34
41
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
35
42
  "--entrypoint", "/usr/bin/pg_basebackup",
36
43
  fetch(:postgres_image_name),
37
44
  "-w", "-h", fetch(:domain), "-p", fetch(:master_container_port),
38
- "-U", "replicator", "-D", fetch(:postgres_data_path), "-v", "-x")
45
+ "-U", "replicator", "-D", fetch(:postgres_data_path), "-v", "-x"
46
+ )
39
47
  end
40
48
  def pg_ssl_key(host)
41
- execute("docker", "run", "--rm", "--user", "root",
49
+ execute(
50
+ "docker", "run", "--rm", "--user", "root",
42
51
  "--entrypoint", "/usr/bin/openssl",
43
52
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
44
53
  fetch(:postgres_image_name), "req", "-nodes", "-newkey", "rsa:2048",
45
54
  "-keyout", fetch(:postgres_ssl_key),
46
55
  "-out", fetch(:postgres_ssl_csr),
47
- "-subj", "\"/C=US/ST=Oregon/L=Portland/O=My Company/OU=Operations/CN=localhost\"")
56
+ "-subj", "\"/C=US/ST=Oregon/L=Portland/O=My Company/OU=Operations/CN=localhost\""
57
+ )
48
58
  end
49
59
  def pg_ssl_crt(host)
50
- execute("docker", "run", "--rm", "--user", "root",
60
+ execute(
61
+ "docker", "run", "--rm", "--user", "root",
51
62
  "--entrypoint", "/usr/bin/openssl",
52
63
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
53
64
  fetch(:postgres_image_name), "req", "-x509", "-text",
54
65
  "-in", fetch(:postgres_ssl_csr),
55
66
  "-key", fetch(:postgres_ssl_key),
56
- "-out", fetch(:postgres_ssl_crt))
67
+ "-out", fetch(:postgres_ssl_crt)
68
+ )
57
69
  end
58
70
  def pg_restore(host, args, clean)
59
- SSHKit.config.output_verbosity = "debug"
60
- execute("docker", "run", "--rm",
71
+ execute(
72
+ "docker", "run", "--rm",
61
73
  "--volume", "/tmp:/tmp:rw",
62
74
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
63
75
  "--entrypoint", "/bin/bash",
64
76
  fetch(:postgres_image_name),
65
77
  "-c", "'/usr/bin/pg_restore", "-U", "postgres",
66
78
  "--host", fetch(:postgres_socket_path), clean,
67
- "-d", args.database_name, "-F", "tar", "-v", "/tmp/#{args.dump_file}'")
68
- SSHKit.config.output_verbosity = fetch(:postgres_log_level)
79
+ "-d", args.database_name, "-F", "tar", "-v", "/tmp/#{args.dump_file}'"
80
+ )
69
81
  end
70
82
  def pg_dump(host, args)
71
- SSHKit.config.output_verbosity = "debug"
72
- execute("docker", "run", "--rm",
83
+ execute(
84
+ "docker", "run", "--rm",
73
85
  "--volume", "/tmp:/tmp:rw",
74
86
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
75
87
  "--entrypoint", "/bin/bash",
76
88
  fetch(:postgres_image_name),
77
89
  "-c", "'/usr/bin/pg_dump", "-U", "postgres",
78
90
  "--host", fetch(:postgres_socket_path), "-F", "tar",
79
- "-v", args.database_name, ">", "/tmp/#{args.dump_file}'")
80
- SSHKit.config.output_verbosity = fetch(:postgres_log_level)
91
+ "-v", args.database_name, ">", "/tmp/#{args.dump_file}'"
92
+ )
81
93
  end
82
94
  def pg_interactive(host)
83
95
  [
@@ -100,44 +112,53 @@ def pg_interactive_print(host)
100
112
  ].join(' ')
101
113
  end
102
114
  def pg_list_databases(host)
103
- capture("docker", "run", "--rm",
115
+ capture(
116
+ "docker", "run", "--rm",
104
117
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
105
118
  "--entrypoint", "/bin/bash",
106
119
  fetch(:postgres_image_name),
107
120
  "-c", "'/usr/bin/psql", "-U", "postgres",
108
121
  "--host", fetch(:postgres_socket_path),
109
- "-a", "-c", "\"\\l\"'").lines.each { |l| info l }
122
+ "-a", "-c", "\"\\l\"'"
123
+ ).lines.each { |l| info l }
110
124
  end
111
125
  def pg_list_roles(host)
112
- capture("docker", "run", "--rm",
126
+ capture(
127
+ "docker", "run", "--rm",
113
128
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
114
129
  "--entrypoint", "/bin/bash",
115
130
  fetch(:postgres_image_name),
116
131
  "-c", "'/usr/bin/psql", "-U", "postgres",
117
132
  "--host", fetch(:postgres_socket_path),
118
- "-c", "\"\\du\"'").lines.each { |l| info l }
133
+ "-c", "\"\\du\"'"
134
+ ).lines.each { |l| info l }
119
135
  end
120
136
  def pg_streaming_master(host)
121
- capture("echo", "\"SELECT", "*", "FROM", "pg_stat_replication;\"", "|",
137
+ capture(
138
+ "echo", "\"SELECT", "*", "FROM", "pg_stat_replication;\"", "|",
122
139
  "docker", "run", "--rm", "--interactive",
123
140
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
124
141
  "--entrypoint", "/bin/bash",
125
142
  fetch(:postgres_image_name),
126
143
  "-c", "'/usr/bin/psql", "-U", "postgres", "-xa",
127
- "--host", "#{fetch(:postgres_socket_path)}'").lines.each { |l| info l }
144
+ "--host", "#{fetch(:postgres_socket_path)}'"
145
+ ).lines.each { |l| info l }
128
146
  end
129
147
  def pg_streaming_slave(host)
130
- capture("echo", "\"SELECT", "now()", "-", "pg_last_xact_replay_timestamp()",
148
+ capture(
149
+ "echo", "\"SELECT", "now()", "-", "pg_last_xact_replay_timestamp()",
131
150
  "AS", "replication_delay;\"", "|",
132
151
  "docker", "run", "--rm", "--interactive",
133
152
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
134
153
  "--entrypoint", "/bin/bash",
135
154
  fetch(:postgres_image_name),
136
155
  "-c", "'/usr/bin/psql", "-U", "postgres",
137
- "--host", "#{fetch(:postgres_socket_path)}'").lines.each { |l| info l }
156
+ "--host", "#{fetch(:postgres_socket_path)}'"
157
+ ).lines.each { |l| info l }
138
158
  end
139
159
  def pg_create_role(db_role, password)
140
- execute("echo", "\"CREATE", "ROLE", "\\\"#{db_role}\\\"",
160
+ execute(
161
+ "echo", "\"CREATE", "ROLE", "\\\"#{db_role}\\\"",
141
162
  "WITH", "LOGIN", "ENCRYPTED", "PASSWORD", "'#{password}'",
142
163
  "REPLICATION", "CREATEDB;\"", "|",
143
164
  "docker", "run", "--rm", "--interactive",
@@ -145,10 +166,12 @@ def pg_create_role(db_role, password)
145
166
  "--entrypoint", "/bin/bash",
146
167
  fetch(:postgres_image_name),
147
168
  "-c", "'/usr/bin/psql", "-U", "postgres",
148
- "--host", "#{fetch(:postgres_socket_path)}'")
169
+ "--host", "#{fetch(:postgres_socket_path)}'"
170
+ )
149
171
  end
150
172
  def pg_create_database(database)
151
- execute("echo", "\"CREATE", "DATABASE", "\\\"#{database[:name]}\\\"",
173
+ execute(
174
+ "echo", "\"CREATE", "DATABASE", "\\\"#{database[:name]}\\\"",
152
175
  "WITH", "OWNER", "\\\"#{database[:db_role]}\\\"", "TEMPLATE",
153
176
  "template0", "ENCODING", "'UTF8';\"", "|",
154
177
  "docker", "run", "--rm", "--interactive",
@@ -156,20 +179,24 @@ def pg_create_database(database)
156
179
  "--entrypoint", "/bin/bash",
157
180
  fetch(:postgres_image_name),
158
181
  "-c", "'/usr/bin/psql", "-U", "postgres",
159
- "--host", "#{fetch(:postgres_socket_path)}'")
182
+ "--host", "#{fetch(:postgres_socket_path)}'"
183
+ )
160
184
  end
161
185
  def pg_grant_database(database)
162
- execute("echo", "\"GRANT", "ALL", "PRIVILEGES", "ON", "DATABASE",
186
+ execute(
187
+ "echo", "\"GRANT", "ALL", "PRIVILEGES", "ON", "DATABASE",
163
188
  "\\\"#{database[:name]}\\\"", "to", "\\\"#{database[:db_role]}\\\";\"", "|",
164
189
  "docker", "run", "--rm", "--interactive",
165
190
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
166
191
  "--entrypoint", "/bin/bash",
167
192
  fetch(:postgres_image_name),
168
193
  "-c", "'/usr/bin/psql", "-U", "postgres",
169
- "--host", "#{fetch(:postgres_socket_path)}'")
194
+ "--host", "#{fetch(:postgres_socket_path)}'"
195
+ )
170
196
  end
171
197
  def pg_role_exists?(db_role)
172
- test("echo", "\"SELECT", "*", "FROM", "pg_user",
198
+ test(
199
+ "echo", "\"SELECT", "*", "FROM", "pg_user",
173
200
  "WHERE", "usename", "=", "'#{db_role}';\"", "|",
174
201
  "docker", "run", "--rm", "--interactive",
175
202
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
@@ -177,22 +204,27 @@ def pg_role_exists?(db_role)
177
204
  fetch(:postgres_image_name),
178
205
  "-c", "'/usr/bin/psql", "-U", "postgres",
179
206
  "--host", "#{fetch(:postgres_socket_path)}'", "|",
180
- "grep", "-q", "'#{db_role}'")
207
+ "grep", "-q", "'#{db_role}'"
208
+ )
181
209
  end
182
210
  def pg_database_exists?(database_name)
183
- test("docker", "run", "--rm",
211
+ test(
212
+ "docker", "run", "--rm",
184
213
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
185
214
  "--entrypoint", "/bin/bash",
186
215
  fetch(:postgres_image_name),
187
216
  "-c", "'/usr/bin/psql", "-U", "postgres",
188
217
  "--host", fetch(:postgres_socket_path), "-lqt", "|",
189
- "cut", "-d\\|", "-f1", "|", "grep", "-w", "#{database_name}'")
218
+ "cut", "-d\\|", "-f1", "|", "grep", "-w", "#{database_name}'"
219
+ )
190
220
  end
191
221
  def pg_database_empty?(database_name)
192
- test("docker", "run", "--rm", "--tty",
222
+ test(
223
+ "docker", "run", "--rm", "--tty",
193
224
  "--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
194
225
  "--entrypoint", "/bin/bash", fetch(:postgres_image_name), "-lc",
195
226
  "'/usr/bin/psql", "-U", "postgres", "-d", database_name,
196
227
  "--host", fetch(:postgres_socket_path),
197
- "-c", "\"\\dt\"", "|", "grep", "-qi", "\"no relations found\"'")
228
+ "-c", "\"\\dt\"", "|", "grep", "-qi", "\"no relations found\"'"
229
+ )
198
230
  end
@@ -2,8 +2,8 @@ namespace :pg do
2
2
  namespace :check do
3
3
 
4
4
  #desc 'Ensure all postgresinator specific settings are set, and warn and exit if not.'
5
- before 'pg:setup', :settings do
6
- require 'resolv' unless defined?(Resolv)
5
+ task :settings => 'deployinator:load_settings' do
6
+ require 'resolv'
7
7
  run_locally do
8
8
  {
9
9
  (File.dirname(__FILE__) + "/examples/config/deploy.rb") => 'config/deploy.rb',
@@ -39,10 +39,11 @@ namespace :pg do
39
39
  end
40
40
  end
41
41
  end
42
+ before 'pg:setup', 'pg:check:settings'
42
43
 
43
44
  namespace :settings do
44
45
  desc 'Print example postgresinator specific settings for comparison.'
45
- task :print do
46
+ task :print => 'deployinator:load_settings' do
46
47
  set :print_all, true
47
48
  Rake::Task['pg:check:settings'].invoke
48
49
  end
@@ -54,7 +55,7 @@ namespace :pg do
54
55
  next unless database[:name] == args.database_name
55
56
  database_found = true
56
57
  end
57
- fatal "Database #{args.domain} not found in the configuration" and exit unless database_found
58
+ fatal "Database #{args.database_name} not found in the configuration" and exit unless database_found
58
59
  end
59
60
  end
60
61
 
@@ -66,7 +67,7 @@ namespace :pg do
66
67
  end
67
68
  end
68
69
 
69
- task :postgres_uid_gid do
70
+ task :postgres_uid_gid => 'deployinator:load_settings' do
70
71
  on roles(:db) do
71
72
  set :postgres_uid, -> {
72
73
  capture("docker", "run", "--rm", "--tty",
@@ -14,9 +14,8 @@ end
14
14
  namespace :postgresinator do
15
15
 
16
16
  set :example, "_example"
17
-
18
17
  desc "Write example config files (with '_example' appended to their names)."
19
- task :write_example_configs do
18
+ task :write_example_configs => 'deployinator:load_settings' do
20
19
  run_locally do
21
20
  execute "mkdir", "-p", "config/deploy", fetch(:postgres_templates_path, 'templates/postgres')
22
21
  {
@@ -40,14 +39,14 @@ namespace :postgresinator do
40
39
 
41
40
  desc 'Write example config files (will overwrite any existing config files).'
42
41
  namespace :write_example_configs do
43
- task :in_place do
42
+ task :in_place => 'deployinator:load_settings' do
44
43
  set :example, ""
45
44
  Rake::Task['postgresinator:write_example_configs'].invoke
46
45
  end
47
46
  end
48
47
 
49
48
  desc 'Write a file showing the built-in overridable settings.'
50
- task :write_built_in do
49
+ task :write_built_in => 'deployinator:load_settings' do
51
50
  run_locally do
52
51
  {
53
52
  'built-in.rb' => 'built-in.rb',
@@ -63,7 +62,7 @@ namespace :postgresinator do
63
62
  # These are the only two tasks using :preexisting_ssh_user
64
63
  namespace :deployment_user do
65
64
  #desc "Setup or re-setup the deployment user, idempotently"
66
- task :setup do
65
+ task :setup => 'deployinator:load_settings' do
67
66
  on roles(:all) do |h|
68
67
  on "#{fetch(:preexisting_ssh_user)}@#{h}" do |host|
69
68
  as :root do
@@ -76,7 +75,7 @@ namespace :postgresinator do
76
75
  end
77
76
  end
78
77
 
79
- task :deployment_user do
78
+ task :deployment_user => 'deployinator:load_settings' do
80
79
  on roles(:all) do |h|
81
80
  on "#{fetch(:preexisting_ssh_user)}@#{h}" do |host|
82
81
  as :root do
@@ -90,7 +89,7 @@ namespace :postgresinator do
90
89
  end
91
90
  end
92
91
 
93
- task :webserver_user do
92
+ task :webserver_user => 'deployinator:load_settings' do
94
93
  on roles(:all) do
95
94
  as :root do
96
95
  unix_user_add(fetch(:webserver_username)) unless unix_user_exists?(fetch(:webserver_username))
@@ -28,7 +28,11 @@ namespace :pg do
28
28
  else
29
29
  pg_confirm_database_overwrite?(args.database_name) ? clean = "--clean" : exit(0)
30
30
  end
31
+ level = SSHKit.config.output_verbosity
32
+ level ||= :info
33
+ SSHKit.config.output_verbosity = :debug
31
34
  pg_restore(host, args, clean)
35
+ SSHKit.config.output_verbosity = level
32
36
  end
33
37
  end
34
38
 
@@ -38,7 +42,11 @@ namespace :pg do
38
42
  if file_exists?("/tmp/#{args.dump_file}")
39
43
  exit unless(pg_confirm_file_overwrite?(args.dump_file))
40
44
  end
45
+ level = SSHKit.config.output_verbosity
46
+ level ||= :info
47
+ SSHKit.config.output_verbosity = :debug
41
48
  pg_dump(host, args)
49
+ SSHKit.config.output_verbosity = level
42
50
  end
43
51
  end
44
52
 
@@ -50,6 +58,27 @@ namespace :pg do
50
58
  end
51
59
  end
52
60
 
61
+ namespace :interactive do
62
+ desc "Enter psql interactive mode on a slave."
63
+ task :slave => 'pg:ensure_setup' do
64
+ run_locally do
65
+ warn "There are no slave instances setup for #{fetch(:stage)}" if roles(:db_slave).length < 1
66
+ if roles(:db_slave).length > 1
67
+ info "There's more than one slave:"
68
+ roles(:db_slave).each_with_index do |slave, index|
69
+ info "#{index}. #{slave}"
70
+ end
71
+ ask :number, roles(:db_slave).each_with_index.map { |_, i| i }.join(", ")
72
+ set :filter, :hosts => [roles(:db_slave)[fetch(:number).to_i].to_s]
73
+ end
74
+ end
75
+ on roles(:db_slave) do |host|
76
+ info "Entering psql interactive mode inside #{host.properties.postgres_container_name} on #{host}"
77
+ system pg_interactive(host)
78
+ end
79
+ end
80
+ end
81
+
53
82
  namespace :interactive do
54
83
  desc "Print the command to enter psql interactive mode on the master."
55
84
  task :print => 'pg:ensure_setup' do
@@ -1,12 +1,13 @@
1
- # vi: ft=config
2
1
  FROM ubuntu:12.04
3
2
  MAINTAINER david amick <docker@davidamick.com>
4
3
 
5
4
  RUN ["/bin/bash", "-c", "apt-get update -qq && apt-get install -qy postgresql-9.1 libpq-dev postgresql-contrib nodejs rsync"]
6
- RUN ["/bin/bash", "-c", "/etc/init.d/postgresql start && /etc/init.d/postgresql stop"]
5
+ RUN ["/bin/bash", "-c", "/etc/init.d/postgresql start && su -c 'psql -c \"create extension tablefunc;\"' postgres && su -c 'psql -c \"create extension ltree;\"' postgres && /etc/init.d/postgresql stop"]
7
6
  RUN ["/bin/bash", "-c", "usermod -a -G www-data postgres"]
8
7
  RUN ["/bin/bash", "-c", "rm /etc/ssl/certs/ssl-cert-snakeoil.pem"]
9
8
  RUN ["/bin/bash", "-c", "rm /etc/ssl/private/ssl-cert-snakeoil.key"]
10
9
 
11
10
  ENTRYPOINT ["/bin/bash"]
12
11
  CMD ["-l"]
12
+
13
+ # snarlysodboxer/postgresql:0.0.2
@@ -7,4 +7,5 @@ set :application, "my_app_name"
7
7
  set :preexisting_ssh_user, ENV['USER']
8
8
  set :deployment_username, "deployer"
9
9
  set :webserver_username, "www-data" # needed for intergration w/ deployinator
10
+ set :postgres_version, "9.1"
10
11
  ### ------------------------------------------------------------------
@@ -72,6 +72,9 @@
72
72
  #
73
73
  # Database administrative login by UNIX sockets
74
74
  local all postgres trust
75
+ <% fetch(:postgres_databases).each do |db| %>
76
+ local all <%= db[:db_role] %> trust
77
+ <% end %>
75
78
 
76
79
  # TYPE DATABASE USER CIDR-ADDRESS METHOD
77
80
  <% if host.has_role?(:db) %>
@@ -42,7 +42,7 @@ ident_file = '<%= fetch(:postgres_config_path) %>/pg_ident.conf' # ident confi
42
42
  # (change requires restart)
43
43
 
44
44
  # If external_pid_file is not explicitly set, no extra PID file is written.
45
- external_pid_file = '<%= fetch(:postgres_socket_path) %>/postgresql-9.1-main.pid' # write an extra PID file
45
+ external_pid_file = '<%= fetch(:postgres_socket_path) %>/postgresql-main.pid' # write an extra PID file
46
46
  # (change requires restart)
47
47
 
48
48
  #------------------------------------------------------------------------------
@@ -1,7 +1,6 @@
1
1
  namespace :pg do
2
2
 
3
- task :ensure_setup => ['pg:check:settings', 'deployinator:sshkit_umask'] do |t, args|
4
- SSHKit.config.output_verbosity = fetch(:postgres_log_level)
3
+ task :ensure_setup => ['deployinator:load_settings', 'pg:check:settings', 'deployinator:sshkit_umask'] do |t, args|
5
4
  Rake::Task['pg:check:settings:database'].invoke(args.database_name) unless args.database_name.nil?
6
5
  Rake::Task['pg:check:settings:domain'].invoke(args.domain) unless args.domain.nil?
7
6
  end
@@ -36,6 +35,7 @@ namespace :pg do
36
35
  end
37
36
  end
38
37
  on roles(:db_slave, :in => :parallel) do |host|
38
+ # TODO check for current streaming, remove container and remove data dir if not current
39
39
  name = host.properties.postgres_container_name
40
40
  unless container_exists?(name)
41
41
  fatal "Master must be running before creating a slave" and exit unless fetch(:master_container_running)
@@ -74,7 +74,7 @@ namespace :pg do
74
74
  end
75
75
 
76
76
  task :install_config_files => [:ensure_setup, 'postgresinator:deployment_user'] do
77
- require 'erb' unless defined?(ERB)
77
+ require 'erb'
78
78
  on roles(:db, :db_slave, :in => :parallel) do |host|
79
79
  host.properties.set :config_file_changed, false
80
80
  as 'root' do
@@ -144,7 +144,10 @@ namespace :pg do
144
144
  def ask_reload_or_restart(name, host)
145
145
  warn "A config file has changed for #{name} on #{host}, please specify " +
146
146
  "whether you would like to have PostgreSQL reload the config, or restart itself"
147
- ask :reload_or_restart, nil
147
+ set :reload_or_restart, ""
148
+ while fetch(:reload_or_restart).empty?
149
+ ask :reload_or_restart, ""
150
+ end
148
151
  case fetch(:reload_or_restart).chomp.downcase
149
152
  when "reload"
150
153
  execute("docker", "kill", "-s", "SIGHUP", name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgresinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-30 00:00:00.000000000 Z
12
+ date: 2016-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.1.3
37
+ version: 0.1.6
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.3
45
+ version: 0.1.6
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -121,3 +121,4 @@ signing_key:
121
121
  specification_version: 3
122
122
  summary: Deploy PostgreSQL
123
123
  test_files: []
124
+ has_rdoc: