Search code examples
postgresqlchef-infravagrantupstartinit.d

Vagrant & Chef - Postgresql not starting on reboot


I decided to create my own chef script to install Postgres. The installation works perfectly fine, but postgres doesn't start on boot when I vagrant reload

Here's my recipes/default.rb:

include_recipe "apt"

apt_repository 'apt.postgresql.org' do
  uri 'http://apt.postgresql.org/pub/repos/apt'
  distribution node["lsb"]["codename"] + '-pgdg'
  components ['main', node["postgres"]["version"]]
  key 'http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc'
  action :add
end

package 'postgresql-' + node["postgres"]["version"] do
    action  :install
end

file "/etc/postgresql/#{node['postgres']['version']}/main/postgresql.conf" do
    action  :delete
end

link "/etc/postgresql/#{node['postgres']['version']}/main/postgresql.conf" do
    to      node["postgres"]["conf_path"]
    action  :create
    notifies :reload, "service[postgresql]", :delayed
end

service "postgresql" do
    action [:enable, :start]
    supports :status=>true, :restart=>true, :start => true, :stop => true, :reload=>true
end

And here's my attributes/default.rb:

default["postgres"]["version"] = "9.3"
default["postgres"]["conf_path"] = "/home/vagrant/postgres/postgresql.conf"

Any help would be greatly appreciated!!

============ EDIT 1 ============

Here is the output when running vagrant up for the first time with chef.log_level = :debug: http://pastebin.com/w8Lp8gzv

Here is /etc/init.d/postgresql: http://pastebin.com/dQ5Zb1yj

Here is /var/log/postgresql/postgresql-9.3-main.log: http://pastebin.com/0Y2RhWvL

============ EDIT 2 ============

I'm now fairly confident that it's my postgresql.conf file, which looks like: http://pastebin.com/rjX89iU0

shared_buffers might be too high...


Solution

  • Turns out the postgresql was starting before the postgersql.conf file was mounted