sous-chefs / postgresql Goto Github PK
View Code? Open in Web Editor NEWDevelopment repository for the postgresql cookbook
Home Page: https://supermarket.chef.io/cookbooks/postgresql
License: Apache License 2.0
Development repository for the postgresql cookbook
Home Page: https://supermarket.chef.io/cookbooks/postgresql
License: Apache License 2.0
Hi,
If I set data_directory
in the recipe it will indeed change the line in postgresq.conf
but how do I ask for the cluster to be created?
In other words, how do I keep the default ['postgresql']['dir']
(I want to keep my config there) but create the cluster in another location?
Hi,
Using Vagrant
Ubuntu 12.04
Chef 11.16.4
Cookbook version 3.4.14
Related recipe postgresql::ruby
Strangest thing, the -v
for the version in the chef gem install pg command is missing.
I do a vagrant destroy
, ensure my hosted chef doesn't have the node or client in there, and do a vagrant up again. It happens about 3 out of the 4 times I test this.
I'm hoping someone can point out what I'm missing because it's getting a little annoying. Thanks a lot.
==> host1: [2014-12-02T05:17:15+00:00] WARN: Current execute[apt-get update]: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:26:in `rescue in from_file'
==> host1: [2014-12-02T05:17:45+00:00] WARN: failed to find gem pg (>= 0) from [http://rubygems.org/]
==> host1:
==> host1: ================================================================================
==> host1: Error executing action `install` on resource 'chef_gem[pg]'
==> host1: ================================================================================
==> host1:
==> host1:
==> host1: Mixlib::ShellOut::ShellCommandFailed
==> host1: ------------------------------------
==> host1: Expected process to exit with [0], but received '1'
==> host1:
==> host1: ---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1:
==> host1: STDOUT:
==> host1:
==> host1: STDERR: ERROR: While executing gem ... (ArgumentError)
==> host1:
==> host1: Illformed requirement [""]
==> host1:
==> host1: ---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1:
==> host1: Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" returned 1
==> host1:
==> host1:
==> host1: Cookbook Trace:
==> host1:
==> host1: ---------------
==> host1: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:55:in `rescue in from_file'
==> host1: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:21:in `from_file'
==> host1: /var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
==> host1: /var/chef/cache/cookbooks/icinga/recipes/pg_database.rb:1:in `from_file'
==> host1:
==> host1: Resource Declaration:
==> host1: ---------------------
==> host1: # In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb
==> host1:
==> host1: 55: chef_gem "pg"
==> host1: 56: rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e
==> host1:
==> host1: Compiled Resource:
==> host1: ------------------
==> host1: # Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:55:in `rescue in from_file'
==> host1:
==> host1: chef_gem("pg") do
==> host1: provider Chef::Provider::Package::Rubygems
==> host1: action :install
==> host1: retries 0
==> host1: retry_delay 2
==> host1: guard_interpreter :default
==> host1: package_name "pg"
==> host1: timeout 900
==> host1: gem_binary "/opt/chef/embedded/bin/gem"
==> host1: cookbook_name "postgresql"
==> host1: recipe_name "ruby"
==> host1: end
==> host1:
==> host1: [2014-12-02T05:17:45+00:00] WARN: Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)
==> host1:
==> host1: ================================================================================
==> host1: Recipe Compile Error in /var/chef/cache/cookbooks/icinga/recipes/pg_database.rb
==> host1: ================================================================================
==> host1:
==> host1: Mixlib::ShellOut::ShellCommandFailed
==> host1: ------------------------------------
==> host1: chef_gem[pg] (postgresql::ruby line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> host1: ---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1: STDOUT:
==> host1: STDERR: ERROR: While executing gem ... (ArgumentError)
==> host1: Illformed requirement [""]
==> host1: ---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1: Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" returned 1
==> host1:
==> host1: Cookbook Trace:
==> host1: ---------------
==> host1: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:55:in `rescue in from_file'
==> host1: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:21:in `from_file'
==> host1: /var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
==> host1: /var/chef/cache/cookbooks/icinga/recipes/pg_database.rb:1:in `from_file'
==> host1:
==> host1: Relevant File Content:
==> host1: ----------------------
==> host1: /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:
==> host1:
==> host1: 48: end
==> host1: 49:
==> host1: 50: node['postgresql']['client']['packages'].each do |pg_pack|
==> host1: 51: resources("package[#{pg_pack}]").run_action(:install)
==> host1: 52: end
==> host1: 53:
==> host1: 54: begin
==> host1: 55>> chef_gem "pg"
==> host1: 56: rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e
==> host1: 57: # Are we an omnibus install?
==> host1: 58: raise if RbConfig.ruby.scan(%r{(chef|opscode)}).empty?
==> host1: 59: # Still here, must be omnibus. Lets make this thing install!
==> host1: 60: Chef::Log.warn 'Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)'
==> host1: 61: gem_dir = e.message.scan(%r{will remain installed in ([^ ]+)}).flatten.first
==> host1: 62: raise unless gem_dir
==> host1: 63: gem_name = File.basename(gem_dir)
==> host1: 64: ext_dir = File.join(gem_dir, 'ext')
==> host1:
==> host1: [2014-12-02T05:17:45+00:00] ERROR: Running exception handlers
==> host1: [2014-12-02T05:17:45+00:00] ERROR: Exception handlers complete
==> host1: [2014-12-02T05:17:45+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> host1: [2014-12-02T05:17:45+00:00] INFO: Sending resource update report (run-id: 8e45442b-cb3f-4f7f-b391-672ce7d47ede)
==> host1: [2014-12-02T05:17:46+00:00] ERROR: chef_gem[pg] (postgresql::ruby line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> host1: ---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1: STDOUT:
==> host1: STDERR: ERROR: While executing gem ... (ArgumentError)
==> host1: Illformed requirement [""]
==> host1: ---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" ----
==> host1: Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "" returned 1
==> host1: [2014-12-02T05:17:46+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Having a play with PostgreSQL and was hoping to install version 9.4 as this is the latest release.
Is it possible to install this version using this cookbook? I'd have assumed adding the following line to my attributes would have worked:
default['postgresql']['version'] = '9.4'
default['postgresql']['password']['postgres'] = 'postgres'
But 9.3 is still installed, tried running the install command manually via terminal and it detects the package.
$ sudo apt-get install postgresql-9.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libpq-dev libpq5 postgresql-client-9.4
Suggested packages:
postgresql-doc-9.4 oidentd ident-server locales-all
The following NEW packages will be installed:
postgresql-9.4 postgresql-client-9.4
The following packages will be upgraded:
libpq-dev libpq5
2 upgraded, 2 newly installed, 0 to remove and 74 not upgraded.
Need to get 4,912 kB of archives.
After this operation, 22.8 MB of additional disk space will be used.
Also looking in the apt sources
$ cat /etc/apt/sources.list.d/apt.postgresql.org.list
deb http://apt.postgresql.org/pub/repos/apt trusty-pgdg main 9.4
As I'm pretty new to this Chef automation I'm probably doing something completely wrong and it's probably blatantly obvious to someone who knows what they are doing :)
Just ran into this issue when my omnibus plugin for vagrant upgraded the chef-client from 11.16 to 12.0.
Fixed by pinning to last known 11.x version that worked.
config.omnibus.chef_version = '11.16.4'
I'm trying to use this recipe to install PostgreSQL on a DigitalOcean VPS.
When running `knife solo cook root@[ip-address]" I get:
create
on resource 'template[/etc/postgresql/9.1/main/postgresql.conf]'Parent directory /etc/postgresql/9.1/main does not exist.
62: template "#{node['postgresql']['dir']}/postgresql.conf" do
63: source "postgresql.conf.erb"
64: owner "postgres"
65: group "postgres"
66: mode 0600
67: notifies change_notify, 'service[postgresql]', :immediately
68: end
69:
template("/etc/postgresql/9.1/main/postgresql.conf") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/etc/postgresql/9.1/main/postgresql.conf"
backup 5
atomic_update true
source "postgresql.conf.erb"
cookbook_name :postgresql
recipe_name "server"
mode 384
owner "postgres"
group "postgres"
end
[2014-01-27T23:56:57-05:00] ERROR: Running exception handlers
[2014-01-27T23:56:57-05:00] ERROR: Exception handlers complete
[2014-01-27T23:56:57-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 12 resources updated
[2014-01-27T23:56:57-05:00] ERROR: template[/etc/postgresql/9.1/main/postgresql.conf](postgresql::server line 62) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.1/main does not exist.
[2014-01-27T23:56:57-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.
On Amazon Linux, when doing yum search postgresql-server, this is the response:
======================================================== Matched: postgresql-server ========================================================= postgresql8.x86_64 : PostgreSQL client programs postgresql8-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql92.x86_64 : PostgreSQL client programs postgresql92-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql92-server-compat.x86_64 : PostgreSQL server config files for backward compatibility postgresql93.x86_64 : PostgreSQL client programs postgresql93-server.x86_64 : The programs needed to create and run a PostgreSQL server
In attributes/default.rb :
default['postgresql']['server']['packages'] = %w{postgresql-server}
While executing postgresql-server package without specifying a version, a first match from the list is installed (in this case postgresql8-server) which results in having postgresql 8.4 server always.
Output from Chef:
================================================================================
Error executing action `create` on resource 'template[/etc/postgresql/9.1/main/postgresql.conf]'
================================================================================
Chef::Exceptions::EnclosingDirectoryDoesNotExist
------------------------------------------------
Parent directory /etc/postgresql/9.1/main does not exist.
Resource Declaration:
---------------------
# In /root/chef/cookbooks/postgresql/recipes/server.rb
62: template "#{node['postgresql']['dir']}/postgresql.conf" do
63: source "postgresql.conf.erb"
64: owner "postgres"
65: group "postgres"
66: mode 0600
67: notifies change_notify, 'service[postgresql]', :immediately
68: end
69:
Compiled Resource:
------------------
# Declared in /root/chef/cookbooks/postgresql/recipes/server.rb:62:in `from_file'
template("/etc/postgresql/9.1/main/postgresql.conf") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
guard_interpreter :default
path "/etc/postgresql/9.1/main/postgresql.conf"
backup 5
atomic_update true
source "postgresql.conf.erb"
cookbook_name :postgresql
recipe_name "server"
owner "postgres"
group "postgres"
mode 384
end
Debug info from the server:
root@server:~# cat /etc/debian_version
7.5
root@server:~# dpkg -s postgresql-9.1
Package: postgresql-9.1
Status: install ok installed
Priority: optional
Section: database
Installed-Size: 16450
Maintainer: Debian PostgreSQL Maintainers <[email protected]>
Architecture: amd64
Version: 9.1.13-0wheezy1
Replaces: postgresql-contrib-9.1 (<< 9.1~beta1-3~), postgresql-plpython-9.1 (<< 9.1.13-0wheezy1)
Depends: libc6 (>= 2.11), libcomerr2 (>= 1.01), libgssapi-krb5-2 (>= 1.8+dfsg), libkrb5-3 (>= 1.6.dfsg.2), libldap-2.4-2 (>= 2.4.7), libpam0g (>= 0.99.7.1), libpq5 (>= 9.1~), libssl1.0.0 (>= 1.0.0), libxml2 (>= 2.7.4), postgresql-client-9.1, postgresql-common (>= 115~), tzdata, ssl-cert, locales
Suggests: oidentd | ident-server, locales-all
Breaks: postgresql-plpython-9.1 (<< 9.1.13-0wheezy1)
Conflicts: postgresql (<< 7.5)
[...]
root@server:~# dpkg -L postgresql-9.1
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/postgresql-9.1
/usr/share/doc/postgresql-9.1/changelog.Debian.gz
/usr/share/doc/postgresql-9.1/changelog.gz
/usr/share/doc/postgresql-9.1/copyright
/usr/share/postgresql
/usr/share/postgresql/9.1
/usr/share/postgresql/9.1/sql_features.txt
/usr/share/postgresql/9.1/postgres.shdescription
/usr/share/postgresql/9.1/postgres.description
/usr/share/postgresql/9.1/postgres.bki
/usr/share/postgresql/9.1/recovery.conf.sample
/usr/share/postgresql/9.1/postgresql.conf.sample
/usr/share/postgresql/9.1/pg_service.conf.sample
/usr/share/postgresql/9.1/pg_ident.conf.sample
/usr/share/postgresql/9.1/pg_hba.conf.sample
/usr/share/postgresql/9.1/system_views.sql
/usr/share/postgresql/9.1/snowball_create.sql
/usr/share/postgresql/9.1/information_schema.sql
/usr/share/postgresql/9.1/conversion_create.sql
/usr/share/postgresql/9.1/tsearch_data
/usr/share/postgresql/9.1/tsearch_data/synonym_sample.syn
/usr/share/postgresql/9.1/tsearch_data/thesaurus_sample.ths
/usr/share/postgresql/9.1/tsearch_data/hunspell_sample.affix
/usr/share/postgresql/9.1/tsearch_data/ispell_sample.affix
/usr/share/postgresql/9.1/tsearch_data/ispell_sample.dict
/usr/share/postgresql/9.1/tsearch_data/danish.stop
/usr/share/postgresql/9.1/tsearch_data/dutch.stop
/usr/share/postgresql/9.1/tsearch_data/english.stop
/usr/share/postgresql/9.1/tsearch_data/finnish.stop
/usr/share/postgresql/9.1/tsearch_data/french.stop
/usr/share/postgresql/9.1/tsearch_data/german.stop
/usr/share/postgresql/9.1/tsearch_data/hungarian.stop
/usr/share/postgresql/9.1/tsearch_data/italian.stop
/usr/share/postgresql/9.1/tsearch_data/norwegian.stop
/usr/share/postgresql/9.1/tsearch_data/portuguese.stop
/usr/share/postgresql/9.1/tsearch_data/russian.stop
/usr/share/postgresql/9.1/tsearch_data/spanish.stop
/usr/share/postgresql/9.1/tsearch_data/swedish.stop
/usr/share/postgresql/9.1/tsearch_data/turkish.stop
/usr/share/postgresql/9.1/tsearch_data/xsyn_sample.rules
/usr/share/postgresql/9.1/tsearch_data/unaccent.rules
/usr/share/postgresql/9.1/timezonesets
/usr/share/postgresql/9.1/timezonesets/Pacific.txt
/usr/share/postgresql/9.1/timezonesets/Indian.txt
/usr/share/postgresql/9.1/timezonesets/India
/usr/share/postgresql/9.1/timezonesets/Europe.txt
/usr/share/postgresql/9.1/timezonesets/Etc.txt
/usr/share/postgresql/9.1/timezonesets/Default
/usr/share/postgresql/9.1/timezonesets/Australia.txt
/usr/share/postgresql/9.1/timezonesets/Australia
/usr/share/postgresql/9.1/timezonesets/Atlantic.txt
/usr/share/postgresql/9.1/timezonesets/Asia.txt
/usr/share/postgresql/9.1/timezonesets/Antarctica.txt
/usr/share/postgresql/9.1/timezonesets/America.txt
/usr/share/postgresql/9.1/timezonesets/Africa.txt
/usr/share/postgresql/9.1/man
/usr/share/postgresql/9.1/man/man1
/usr/share/postgresql/9.1/man/man1/postmaster.1.gz
/usr/share/postgresql/9.1/man/man1/postgres.1.gz
/usr/share/postgresql/9.1/man/man1/pg_resetxlog.1.gz
/usr/share/postgresql/9.1/man/man1/pg_ctl.1.gz
/usr/share/postgresql/9.1/man/man1/pg_controldata.1.gz
/usr/share/postgresql/9.1/man/man1/initdb.1.gz
/usr/share/postgresql/9.1/extension
/usr/share/postgresql/9.1/extension/plpgsql.control
/usr/share/postgresql/9.1/extension/plpgsql--unpackaged--1.0.sql
/usr/share/postgresql/9.1/extension/plpgsql--1.0.sql
/usr/share/locale
/usr/share/locale/ta
/usr/share/locale/ta/LC_MESSAGES
/usr/share/locale/ta/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/zh_TW
/usr/share/locale/zh_TW/LC_MESSAGES
/usr/share/locale/zh_TW/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/zh_TW/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/zh_CN
/usr/share/locale/zh_CN/LC_MESSAGES
/usr/share/locale/zh_CN/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/zh_CN/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/tr
/usr/share/locale/tr/LC_MESSAGES
/usr/share/locale/tr/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/tr/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/tr/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/tr/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/tr/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/tr/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/sv
/usr/share/locale/sv/LC_MESSAGES
/usr/share/locale/sv/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/sv/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/ru
/usr/share/locale/ru/LC_MESSAGES
/usr/share/locale/ru/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/ru/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/ro
/usr/share/locale/ro/LC_MESSAGES
/usr/share/locale/ro/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/ro/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/ro/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/ro/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/ro/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/pt_BR
/usr/share/locale/pt_BR/LC_MESSAGES
/usr/share/locale/pt_BR/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/pt_BR/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/pl
/usr/share/locale/pl/LC_MESSAGES
/usr/share/locale/pl/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/pl/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/ko
/usr/share/locale/ko/LC_MESSAGES
/usr/share/locale/ko/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/ko/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/ko/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/ko/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/ja
/usr/share/locale/ja/LC_MESSAGES
/usr/share/locale/ja/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/ja/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/it
/usr/share/locale/it/LC_MESSAGES
/usr/share/locale/it/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/it/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/it/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/it/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/it/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/it/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/it/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/fr
/usr/share/locale/fr/LC_MESSAGES
/usr/share/locale/fr/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/fr/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/es
/usr/share/locale/es/LC_MESSAGES
/usr/share/locale/es/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/es/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/es/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/es/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/es/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/es/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/es/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/de
/usr/share/locale/de/LC_MESSAGES
/usr/share/locale/de/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/de/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/de/LC_MESSAGES/postgres-9.1.mo
/usr/share/locale/de/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/de/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/de/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/de/LC_MESSAGES/initdb-9.1.mo
/usr/share/locale/cs
/usr/share/locale/cs/LC_MESSAGES
/usr/share/locale/cs/LC_MESSAGES/plpython-9.1.mo
/usr/share/locale/cs/LC_MESSAGES/plpgsql-9.1.mo
/usr/share/locale/cs/LC_MESSAGES/pg_resetxlog-9.1.mo
/usr/share/locale/cs/LC_MESSAGES/pg_ctl-9.1.mo
/usr/share/locale/cs/LC_MESSAGES/pg_controldata-9.1.mo
/usr/share/locale/cs/LC_MESSAGES/initdb-9.1.mo
/usr/lib
/usr/lib/postgresql
/usr/lib/postgresql/9.1
/usr/lib/postgresql/9.1/lib
/usr/lib/postgresql/9.1/lib/ascii_and_mic.so
/usr/lib/postgresql/9.1/lib/cyrillic_and_mic.so
/usr/lib/postgresql/9.1/lib/euc_cn_and_mic.so
/usr/lib/postgresql/9.1/lib/euc_jp_and_sjis.so
/usr/lib/postgresql/9.1/lib/euc_kr_and_mic.so
/usr/lib/postgresql/9.1/lib/euc_tw_and_big5.so
/usr/lib/postgresql/9.1/lib/latin2_and_win1250.so
/usr/lib/postgresql/9.1/lib/latin_and_mic.so
/usr/lib/postgresql/9.1/lib/utf8_and_ascii.so
/usr/lib/postgresql/9.1/lib/utf8_and_big5.so
/usr/lib/postgresql/9.1/lib/utf8_and_cyrillic.so
/usr/lib/postgresql/9.1/lib/utf8_and_euc2004.so
/usr/lib/postgresql/9.1/lib/utf8_and_euc_cn.so
/usr/lib/postgresql/9.1/lib/utf8_and_euc_jp.so
/usr/lib/postgresql/9.1/lib/utf8_and_euc_kr.so
/usr/lib/postgresql/9.1/lib/utf8_and_euc_tw.so
/usr/lib/postgresql/9.1/lib/utf8_and_gb18030.so
/usr/lib/postgresql/9.1/lib/utf8_and_gbk.so
/usr/lib/postgresql/9.1/lib/utf8_and_iso8859.so
/usr/lib/postgresql/9.1/lib/utf8_and_iso8859_1.so
/usr/lib/postgresql/9.1/lib/utf8_and_johab.so
/usr/lib/postgresql/9.1/lib/utf8_and_sjis.so
/usr/lib/postgresql/9.1/lib/utf8_and_sjis2004.so
/usr/lib/postgresql/9.1/lib/utf8_and_uhc.so
/usr/lib/postgresql/9.1/lib/utf8_and_win.so
/usr/lib/postgresql/9.1/lib/euc2004_sjis2004.so
/usr/lib/postgresql/9.1/lib/libpqwalreceiver.so
/usr/lib/postgresql/9.1/lib/plpgsql.so
/usr/lib/postgresql/9.1/lib/dict_snowball.so
/usr/lib/postgresql/9.1/lib/pg_upgrade_support.so
/usr/lib/postgresql/9.1/lib/tsearch2.so
/usr/lib/postgresql/9.1/bin
/usr/lib/postgresql/9.1/bin/initdb
/usr/lib/postgresql/9.1/bin/pg_controldata
/usr/lib/postgresql/9.1/bin/pg_ctl
/usr/lib/postgresql/9.1/bin/pg_resetxlog
/usr/lib/postgresql/9.1/bin/pg_test_fsync
/usr/lib/postgresql/9.1/bin/pg_upgrade
/usr/lib/postgresql/9.1/bin/postgres
/usr/share/doc/postgresql-9.1/README.Debian.gz
/usr/lib/postgresql/9.1/bin/postmaster
As you can see, the APT package doesn't create the /etc/postgresql/
directory. Please let me know if you need more information.
I am trying to setup a fairly simple Vagrantfile that boots a VM with postgresql and creates a couple of users and databases using hw-cookbooks/database. In the end I need access to the database from the host machine, so I change the pg_hba.conf
by setting a couple of attributes in the Vagrantfile:
chef.json = {
"postgresql" => {
"version" => "9.3",
"password" => {
"postgres" => "postgres",
},
"config" => {
"listen_addresses" => "*"
},
"pg_hba" => [
{ "type" => 'host', "db" => 'all', "user" => 'all', "addr" => '10.0.0.0/16', "method" => 'md5' },
{ "type" => 'local', "db" => 'all', "user" => 'all', "addr" => '', "method" => 'trust' }
]
}
}
Now, when I boot the VM for the first time I get FATAL: Peer authentication failed for user "postgres"
. When I reboot the VM and run chef again everything works as it should, but I destroy and reprovision the VM a couple of times per month and it's just cumbersome.
I also see this in my log:
INFO: template[/etc/postgresql/9.3/main/pg_hba.conf] not queuing delayed action restart on service[postgresql] (delayed), as it's already been queued
So my guess is this has to do with the service notification having been changed from :immediately
to :delayed
and therefore when I try to create the users and databases during the initial convergence run the default pg_hba.conf
is still in effect.
Am I doing something wrong? Help would be appreciated.
(using chef-solo)
In the README it says that node['postgresql']['password']['postgres'] must be a hash of the real password (in the format md5#{some_string_of_hex})
Expected behaviour:
Setting node['postgresql']['password']['postgres'] to a string which does not begin with 'md5' disables interactive password access.
Observed behaviour:
When I set the password to some random string (eg: bb77d0d3b3f239fa5db73bdf27b8d29a, which happens to lack the 'md5' prefix), I can use this string clear text on the interactive password prompt of psql.
Solutions:
Document this behaviour?
Remove this functionality?
It appears you can not run the initdb via the service in Centos7 -
[vagrant@java-app-centos-70 log]$ sudo /sbin/service postgresql-9.3 initdb
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
sudo /usr/pgsql-9.3/bin/postgresql93-setup initdb
works, though is not in anyones path, so not sure how to cleanly merge that into the code, or what versions of postgres it would be used for.
https://github.com/hw-cookbooks/postgresql/blob/43f0945bf525fbb81d5d5557fefb83cc5675ff85/recipes/server_redhat.rb#L78-L90
- create new file /etc/sysconfig/pgsql/postgresql-9.3[2014-10-05T14:55:01+00:00] INFO: template[/etc/sysconfig/pgsql/postgresql-9.3] updated file contents /etc/sysconfig/pgsql/postgresql-9.3
- update content in file /etc/sysconfig/pgsql/postgresql-9.3 from none to 3359a0
--- /etc/sysconfig/pgsql/postgresql-9.3 2014-10-05 14:55:01.983335521 +0000
+++ /tmp/chef-rendered-template20141005-10645-ocu22x 2014-10-05 14:55:01.983335521 +0000
@@ -1 +1,3 @@
+PGDATA=/var/lib/pgsql/9.3/data
+PGPORT=5432[2014-10-05T14:55:01+00:00] INFO: template[/etc/sysconfig/pgsql/postgresql-9.3] mode changed to 644
- change mode from '' to '0644'
- restore selinux security context
* execute[/sbin/service postgresql-9.3 initdb ] action run[2014-10-05T14:55:02+00:00] INFO: Processing execute[/sbin/service postgresql-9.3 initdb ] action run (postgresql::server_redhat line 86)
================================================================================
Error executing action `run` on resource 'execute[/sbin/service postgresql-9.3 initdb ]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
---- Begin output of /sbin/service postgresql-9.3 initdb ----
STDOUT:
STDERR: The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
---- End output of /sbin/service postgresql-9.3 initdb ----
Ran /sbin/service postgresql-9.3 initdb returned 2
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/postgresql/recipes/server_redhat.rb
86: execute "/sbin/service #{svc_name} initdb #{initdb_locale}" do
87: not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
88: end
89:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/postgresql/recipes/server_redhat.rb:86:in `from_file'
execute("/sbin/service postgresql-9.3 initdb ") do
action "run"
retries 0
retry_delay 2
guard_interpreter :default
command "/sbin/service postgresql-9.3 initdb "
backup 5
returns 0
cookbook_name "postgresql"
recipe_name "server_redhat"
not_if { #code block }
end
[2014-10-05T14:55:02+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-10-05T14:55:02+00:00] INFO: template[/etc/sysconfig/pgsql/postgresql-9.3] sending restart action to service[postgresql] (delayed)
* service[postgresql] action restart[2014-10-05T14:55:02+00:00] INFO: Processing service[postgresql] action restart (postgresql::server_redhat line 92)
================================================================================
Error executing action `restart` on resource 'service[postgresql]'
================================================================================
Chef::Exceptions::Exec
----------------------
/bin/systemctl restart postgresql-9.3 returned 1, expected 0
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/postgresql/recipes/server_redhat.rb
92: service "postgresql" do
93: service_name svc_name
94: supports :restart => true, :status => true, :reload => true
95: action [:enable, :start]
96: end
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/postgresql/recipes/server_redhat.rb:92:in `from_file'
service("postgresql") do
provider Chef::Provider::Service::Systemd
action [:enable, :start]
supports {:restart=>true, :status=>true, :reload=>true}
retries 0
retry_delay 2
guard_interpreter :default
service_name "postgresql-9.3"
pattern "postgresql"
cookbook_name "postgresql"
recipe_name "server_redhat"
end
Running handlers:
[2014-10-05T14:55:02+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-05T14:55:02+00:00] ERROR: Exception handlers complete
[2014-10-05T14:55:02+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
Chef Client failed. 37 resources updated in 592.055884004 seconds
[2014-10-05T14:55:02+00:00] ERROR: Chef::Exceptions::MultipleFailures
[2014-10-05T14:55:02+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <java-app-centos-70>.
>>>>>> Please see .kitchen/logs/java-app-centos-70.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-client -z --config /tmp/kitchen/client.rb --log_level info --json-attributes /tmp/kitchen/dna.json]
>>>>>> ----------------------
postgresql_database_user node['app']['username'] do
connection postgresql_connection_info
password node['app']['password']
privileges [:superuser] <-- like this?
action [ :create, :grant]
end
If the pg_tune recipe is used and a max_connections value is supplied that isn't less than the MB of total memory on the server, then the binaryround calculation for work_mem will never complete.
Example, a server with "memory.total: 1014580kB" will produce a value for mem in MB of 990 here: https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L138
This mem = 990 will then be used to calculate the work_mem value here: https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L197. If for example we are using the 'web' model, then the calculation mem / con
will evaluate to zero for any value where con is greater than mem, for example if max_connections = 1000.
The line here https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L223 will then call the binaryround
method with a value of zero which will cause the while loop here https://github.com/hw-cookbooks/postgresql/blob/master/libraries/default.rb#L47 to never exit since
2*((0 / 2).floor) == 0
Not sure of the right approach here but a test could be inserted at https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L204 to ensure zero is not passed e.g.
# Ensure at least 1MB of work_mem is made available
if (work_mem < 1)
work_mem = 1
end
Thoughts?
Every time the server.rb recipe is run, it runs a shell command to reset the postgres password to the node[:postgresql][:password][:postgres] attribute. The comment above it says that the cookbook does not have access to the plaintext password.
However, in the case where the recipe has set the password automatically around line 47, the plaintext password is saved in the attribute. In fact, if the attribute does not start with md5, it can be assured to be a plain-text password.
Please bring back the old behavior, where (if the stored password is plaintext) the recipe will attempt to authenticate with the stored password before trying to reset it.
The only real reason is that error messages show up in the postgresql log if the password is attempted to be altered while the server is running as a hot_standby.
The attributes file sets ssl=on in the postgresql.conf file, but it does not create a server.key and server.pem file in the data directory. I am on Debian, so my previous fix has been to recreate the server.key and server.pem symlink to the apppropriate snakeoil files in /etc/ssl. Now I add the ssl_cert_file and ssl_key_file attributes to the environment to point to the /etc/ssl snakeoil files.
I'm sure I'm doing something wrong here. Apologies if this is a dumb question. This is a Centos 6 system, and I've specified to use the pgdg Yum repo and version 9.3:
override['postgresql']['enable_pgdg_yum'] = true
override['postgresql']['version'] = '9.3'
The pgdg repo is added and activated, but Chef goes ahead and installs version 8.4 instead.
[2014-08-29T09:38:47-04:00] INFO: Processing package[pgdg-centos93] action install (postgresql::yum_pgdg_postgresql line 43)
[2014-08-29T09:38:47-04:00] DEBUG: package[pgdg-centos93] checking rpm status
[2014-08-29T09:38:47-04:00] DEBUG: package[pgdg-centos93] checking install state
[2014-08-29T09:38:47-04:00] DEBUG: package[pgdg-centos93] current version is 9.3-1
[2014-08-29T09:38:47-04:00] DEBUG: package[pgdg-centos93] is already installed - nothing to do
[2014-08-29T09:38:47-04:00] INFO: Processing package[postgresql-devel] action install (postgresql::client line 36)
[2014-08-29T09:38:49-04:00] DEBUG: package[postgresql-devel] checking yum info for postgresql-devel
[2014-08-29T09:38:49-04:00] DEBUG: package[postgresql-devel] installed version: (none) candidate version: 8.4.20-1.el6_5
[2014-08-29T09:38:49-04:00] INFO: package[postgresql-devel] installing postgresql-devel-8.4.20-1.el6_5 from updates repository
Have I missed something obvious here?
Thanks much.
No matter what is specified in the pg_hba
attribute, the cookbook always deploys the following rule:
This seems like an anti-pattern, as it appears to the user that he has full control over the pg_hba.conf
settings using the attribute, which is not the case. It's furthermore not possible to not set the local permissions, which could be a security issue (only a minor one though, as it is only affecting UNIX sockets).
I think the permission line can/ should be removed/ migrated to the default pg_hba
attribute.
In attributes/default.rb, add at line 256:
"20" => {
"x86_64" => "http://yum.postgresql.org/9.3/fedora/fedora-20-x86_64/pgdg-fedora93-9.3-1.noarch.rpm"
},
I'm always facing this setting up postgresql database. I'm not sure why would this fail...
Gem::Installer::ExtensionBuildError
-----------------------------------
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
When using the postgresql cookbook for a slave database, the log gets spammed with the following errors
2013-10-11 08:07:43 CEST [8490] postgres@postgres ERROR: cannot execute ALTER ROLE in a read-only transaction
2013-10-11 08:07:43 CEST [8490] postgres@postgres STATEMENT: ALTER ROLE postgres ENCRYPTED PASSWORD '<passwd>';
One could simply add a
not_if "test -f #{node['postgresql']['config']['data_directory']}/recovery.conf"
But I think it would be cleaner to default to not setting a password for the postgres user (this is the default, as there's a pg_hba rule in place), and create an attribute if this is actually wanted:
node['postgresql']['server']['generate_password'] = true
When specifying a specific version to use, it should use this version not only for the server packages, but also for client and contrib
Not sure what about libpq5 and libpq-dev, as they only seem to be available in the latest version. Was this maybe the reason why contrib and client versions are hardcoded?
A possible solution would be something like this:
diff --git a/attributes/default.rb b/attributes/default.rb
index 641c9c5..d13aabb 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -62,13 +62,15 @@ when "ubuntu"
default['postgresql']['server']['service_name'] = "postgresql"
end
- default['postgresql']['client']['packages'] = %w{postgresql-client libpq-dev}
if node['postgresql']['enable_pgdg_apt']
default['postgresql']['server']['packages'] = ["postgresql-#{node['postgresql']['version']}"]
+ default['postgresql']['client']['packages'] = ["postgresql-client-#{node['postgresql']['version']}", 'libpq-dev']
+ default['postgresql']['contrib']['packages'] = ["postgresql-contrib-#{node['postgresql']['version']}"]
else
+ default['postgresql']['client']['packages'] = %w{postgresql-client libpq-dev}
default['postgresql']['server']['packages'] = %w{postgresql}
+ default['postgresql']['contrib']['packages'] = %w{postgresql-contrib}
end
- default['postgresql']['contrib']['packages'] = %w{postgresql-contrib}
Due to - what I believe is bug caused by a typo - on this line https://github.com/hw-cookbooks/postgresql/blob/develop/recipes/server_redhat.rb#L80 , my cook on an opensuse vm broke on line 82 (https://github.com/hw-cookbooks/postgresql/blob/develop/recipes/server_redhat.rb#L82) after upgrading from 3.4.2 to 3.4.14 .
I was trying to use the databox cookbook to create databases in Postgresql during Chef Solo provisioning of a Vagrant VM. I kept getting the error below, which I traced to databox::postgresql
's call to postgresql::ruby
. Running postgresql::ruby
directly in my run list produces the same error.
Logging into the VM and running sudo /opt/ruby/bin/gem install pg
works, and the rerunning vagrant provision
works too. However, as I understand it, the whole point of the postgresql::ruby
task is that it installs this gem!
(A complete example Vagrant VM configuration can be found in https://github.com/kohenkatz/chef-postgresql-SSCCE)
Here is the output from a Chef run that runs only this recipe (edited slightly for readability):
Running chef-solo...
[2014-07-23T19:33:52+00:00] INFO: Forking chef instance to converge...
[2014-07-23T19:33:52+00:00] INFO: *** Chef 11.12.8 ***
[2014-07-23T19:33:52+00:00] INFO: Chef-client pid: 1627
[2014-07-23T19:33:53+00:00] INFO: Setting the run_list to ["postgresql::ruby"] from CLI options
[2014-07-23T19:33:53+00:00] INFO: Run List is [recipe[postgresql::ruby]]
[2014-07-23T19:33:53+00:00] INFO: Run List expands to [postgresql::ruby]
[2014-07-23T19:33:53+00:00] INFO: Starting Chef Run for vm
[2014-07-23T19:33:53+00:00] INFO: Running start handlers
[2014-07-23T19:33:53+00:00] INFO: Start handlers complete.
[2014-07-23T19:33:57+00:00] INFO: execute[apt-get update] ran successfully
[2014-07-23T19:34:09+00:00] INFO: package[ncurses-dev] is a virtual package, actually acting on package[libncurses5-dev]
================================================================================
Error executing action `install` on resource 'chef_gem[pg]'
================================================================================
LoadError
---------
cannot load such file -- pg
Cookbook Trace:
---------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:25:in `from_file'
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb
58: chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "pg"
version "0.17.1"
cookbook_name :postgresql
recipe_name "ruby"
end
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb
================================================================================
LoadError
---------
chef_gem[pg] (postgresql::ruby line 58) had an error: LoadError: cannot load such file -- pg
Cookbook Trace:
---------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:25:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:
18: # limitations under the License.
19: #
20:
21: # Load the pgdgrepo_rpm_info method from libraries/default.rb
22: ::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
23:
24: begin
25>> require 'pg'
26: rescue LoadError
27:
28: if platform_family?('ubuntu', 'debian')
29: e = execute 'apt-get update' do
30: action :nothing
31: end
32: e.run_action(:run) unless ::File.exists?('/var/lib/apt/periodic/update-success-stamp')
33: end
34:
[2014-07-23T19:34:29+00:00] ERROR: Running exception handlers
[2014-07-23T19:34:29+00:00] ERROR: Exception handlers complete
[2014-07-23T19:34:29+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-07-23T19:34:29+00:00] ERROR: chef_gem[pg] (postgresql::ruby line 58) had an error: LoadError: cannot load such file -- pg
[2014-07-23T19:34:29+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
I'm not doing anything unusual in this failing run - the VM is a stock Vagrant Ubuntu 14.04 x64 image built with Packer - and the only thing Packer did to the image is installing Chef and the VirtualBox extensions.
Chef is version 11.12.8
listen_addresses is one of the parameters in postgresql.conf that requires a full service restart to apply. However, the cookbook only does a service reload whenever the config file is changed. This causes fresh PostgreSQL servers, which default to listening only on localhost, to not be accessible to our application servers without manual tweaking.
I'm using chef-solo to provision a server. Thus, I followed the Chef Solo Note instructions for setting up JSON attributes. However, the password isn't being set because I cannot login with any password. Are there additional steps that I need to follow here?
you put so much logic into the attributes file that you've made it very difficult and painstaking to wrap the cookbook. for example, just to change from version 9.1 to 9.4 on debian, you need ALL of the following config (including where I re-initialize the node[:postgres][:config] hash to {} ). put ur logic in your recipes and resources, not in the attributes.
include_attribute 'postgresql'
default['postgresql']['version'] = '9.4'
default['postgresql']['client']['packages'] = ["postgresql-client-#{node['postgresql']['version']}", "libpq-dev"]
default['postgresql']['server']['packages'] = ["postgresql-#{node['postgresql']['version']}"]
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-#{node['postgresql']['version']}"]
default['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
default['postgresql']['config'] = {}
default['postgresql']['config']['data_directory'] = "/var/lib/postgresql/#{node['postgresql']['version']}/main"
default['postgresql']['config']['hba_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_hba.conf"
default['postgresql']['config']['ident_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_ident.conf"
default['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/#{node['postgresql']['version']}-main.pid"
default['postgresql']['config']['listen_addresses'] = 'localhost'
default['postgresql']['config']['port'] = 5432
default['postgresql']['config']['max_connections'] = 100
node['postgresql']['version'].to_f >= 9.3
default['postgresql']['config']['shared_buffers'] = '24MB'
default['postgresql']['config']['max_fsm_pages'] = 153600 if node['postgresql']['version'].to_f < 8.4
default['postgresql']['config']['log_line_prefix'] = '%t '
default['postgresql']['config']['datestyle'] = 'iso, mdy'
default['postgresql']['config']['default_text_search_config'] = 'pg_catalog.english'
default['postgresql']['config']['ssl'] = true
default['postgresql']['config']['ssl_cert_file'] = '/etc/ssl/certs/ssl-cert-snakeoil.pem' if node['postgresql']['version'].to_f >= 9.2
default['postgresql']['config']['ssl_key_file'] = '/etc/ssl/private/ssl-cert-snakeoil.key'if node['postgresql']['version'].to_f >= 9.2
In case then you are trying to install pg_stat_statements extension you will encounter 'could not access file "pg_stat_statements": No such file or directory' error during PostgreSQL server restart.
The thing is that then you defined default['postgresql']['config']['shared_preload_libraries'] = 'pg_stat_statements' as mentioned in notes chef will try to restart PostgreSQL server right before installing this extension itself which will lead to error.
Looks like the latest version of openssl cookbook just changed this namespace to OpenSSLCookbook
So, need matching patch here and update metadata to point to >= 3.0.0 of that cookbook
This what I'm getting while trying to install the cookbook via Berkshelf.
The Conflicts is with the cookbook nginx, the weird thing is that the dependencies for postgresql has not an specific version apt and build-essential
Unable to satisfy constraints on package postgresql due to solution constraint (cookbooks = 0.1.0). Solution constraints that may result in a constraint on postgresql: [(cookbooks = 0.1.0) -> (postgresql ~> 2.6)], [(postgresql = 3.3.4)]
Demand that cannot be met: (cookbooks = 0.1.0)
Artifacts for which there are conflicting dependencies: postgresql = 3.3.4 -> [(apt ~> 2.2), (build-essential ~> 2.0), (openssl >= 0.0.0), (apt >= 0.0.0), (build-essential >= 0.0.0)]Unable to find a solution for demands: apt (2.3.10), bluepill (2.3.1), build-essential (2.0.0), cookbooks (0.1.0), java (1.22.0), nginx (2.6.2), ohai (1.1.12), rbenv (0.7.3), rsyslog (1.12.2), ruby_build (0.8.1), runit (1.5.10), yum (3.2.0), yum-epel (0.3.6), postgresql (3.3.4)
Manually installing gcc makes the cookbook work again.
Stacktrace from failed run:
Compiling Cookbooks...
[2014-10-27T15:37:48+00:00] INFO: WindowsPackage lightweight resource already initialized -- overriding!
Recipe: postgresql::client
* package[postgresql-devel] action install[2014-10-27T15:37:49+00:00] INFO: Processing package[postgresql-devel] action install (postgresql::client line 31)
(up to date)
Recipe: postgresql::ruby
* chef_gem[pg] action install[2014-10-27T15:37:58+00:00] INFO: Processing chef_gem[pg] action install (postgresql::ruby line 55)
================================================================================
Error executing action `install` on resource 'chef_gem[pg]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:983:in `block in find_header'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:982:in `find_header'
from extconf.rb:48:in `<main>'
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:55:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:21:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb
55: chef_gem "pg"
56: rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:55:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "pg"
version "0.17.1"
timeout 900
gem_binary "/opt/chef/embedded/bin/gem"
cookbook_name "postgresql"
recipe_name "ruby"
end
[2014-10-27T15:38:03+00:00] WARN: Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)
* execute[generate pg gem Makefile] action run[2014-10-27T15:38:03+00:00] INFO: Processing execute[generate pg gem Makefile] action run (postgresql::ruby line 86)
================================================================================
Error executing action `run` on resource 'execute[generate pg gem Makefile]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
STDOUT: checking for pg_config... yes
STDERR: Using config values from /usr/bin/pg_config
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from extconf.rb:52:in `<main>'
---- End output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
Ran PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:92:in `rescue in rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:54:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:21:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb
86: lib_builder = execute 'generate pg gem Makefile' do
87: # [COOK-3490] pg gem install requires full path on RHEL
88: command "PATH=$PATH:/usr/pgsql-#{node['postgresql']['version']}/bin #{RbConfig.ruby} extconf.rb"
89: cwd ext_dir
90: action :nothing
91: end
92: lib_builder.run_action(:run)
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:86:in `rescue in rescue in from_file'
execute("generate pg gem Makefile") do
action [:nothing]
retries 0
retry_delay 2
guard_interpreter :default
command "PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb"
backup 5
cwd "/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext"
returns 0
cookbook_name "postgresql"
recipe_name "ruby"
end
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/database/recipes/postgresql.rb
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
execute[generate pg gem Makefile] (postgresql::ruby line 86) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
STDOUT: checking for pg_config... yes
STDERR: Using config values from /usr/bin/pg_config
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from extconf.rb:52:in `<main>'
---- End output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
Ran PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:92:in `rescue in rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:54:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:21:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:
85:
86: lib_builder = execute 'generate pg gem Makefile' do
87: # [COOK-3490] pg gem install requires full path on RHEL
88: command "PATH=$PATH:/usr/pgsql-#{node['postgresql']['version']}/bin #{RbConfig.ruby} extconf.rb"
89: cwd ext_dir
90: action :nothing
91: end
92>> lib_builder.run_action(:run)
93:
94: lib_maker = execute 'make pg gem lib' do
95: command 'make'
96: cwd ext_dir
97: action :nothing
98: end
99: lib_maker.run_action(:run)
100:
101: lib_installer = execute 'install pg gem lib' do
Running handlers:
[2014-10-27T15:38:03+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-27T15:38:03+00:00] ERROR: Exception handlers complete
[2014-10-27T15:38:03+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 16.680772034 seconds
[2014-10-27T15:38:03+00:00] ERROR: execute[generate pg gem Makefile] (postgresql::ruby line 86) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
STDOUT: checking for pg_config... yes
STDERR: Using config values from /usr/bin/pg_config
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from extconf.rb:52:in `<main>'
---- End output of PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb ----
Ran PATH=$PATH:/usr/pgsql-9.0/bin /opt/chef/embedded/bin/ruby extconf.rb returned 1
[2014-10-27T15:38:03+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Hi,
This cookbook was transferred from Opscode to Heavywater; the CONTRIBUTING.md
still mentions Opscode CLA and using the Jira. It should be updated to reflect what Heavywater wants.
Thanks!
Hello,
cookbook fails to finish (kitchen test) with default and modificated settings.
I'm keep getting this:
* Parent directory /etc/postgresql/9.1/main does not exist.
================================================================================
Error executing action `create` on resource 'template[/etc/postgresql/9.1/main/postgresql.conf]'
================================================================================
Chef::Exceptions::EnclosingDirectoryDoesNotExist
------------------------------------------------
Parent directory /etc/postgresql/9.1/main does not exist.
Am I missing some configuration, or this is bug in cookbook?
Like #140, running the cookbook with default settings on Ubuntu 14.10 fails because postgresql-client-9.3 is not there as an install candidate. The version for 14.10 looks to be postgresql-client-9.4.
When my postgresql config is:
name "postgres_db"
description "The base role for systems that have postgres"
run_list "recipe[postgresql::server]",
"recipe[postgresql::ruby]"
default_attributes postgresql: {
config: {
listen_addresses: '*',
ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key",
ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem",
data_directory: '/opt/paybyphone/postgres'
},
password: { postgres: 'postgres' },
version: "9.3",
pg_hba: [
{type: 'local', db: 'all', user: 'postgres', addr: nil, :method => 'ident'},
{type: 'local', db: 'all', user: 'all', addr: nil, :method => 'ident'},
{type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', :method => 'md5' },
{type: 'host', db: 'all', user: 'all', addr: '10.0.2.0/24', :method => 'md5' },
{type: 'host', db: 'all', user: 'all', addr: '10.0.3.0/24', :method => 'md5' },
{type: 'host', db: 'all', user: 'all', addr: '192.168.42.0/24', :method => 'md5' },
],
enable_pgdg_apt: 'true',
}
Then the 'data_directory' config piece breaks the install.
I get the following in my output:
Running handlers:�[0m
[2014-05-15T07:41:36-07:00] ERROR: Running exception handlers
Running handlers complete
�[0m
[2014-05-15T07:41:36-07:00] ERROR: Exception handlers complete
[2014-05-15T07:41:36-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 28 resources updated in 65.266902432 seconds�[0m
[2014-05-15T07:41:36-07:00] ERROR: service[postgresql] (postgresql::server_debian line 30) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.3 database server
* Error: pid file is invalid, please manually kill the stale server process.
...fail!
I'm a little confused as to why this config works from the standpoint of being available in the config but then breaks on restart.
full output here: http://tny.cz/843cbe61
Data Directory is available as a config in attributes.rb
default['postgresql']['config']['data_directory'] = "/var/lib/postgresql/#{node['postgresql']['version']}/main"
Am I missing something fundamental?
If you run the cookbook with default settings, it fails on Ubuntu 14.04. The cookbook doesn't find a install candidate, cause it trys to install the 9.1 packages which are in Ubuntu 14.04 not available and comes with 9.3. You can get around this issue, by setting the postgres version attribute to 9.3 instead leaving on default.
Hi there,
As I use this recipe to install postgresql, I run into this error:
FATAL: could not access private key file "/etc/ssl/private/ssl-cert-snakeoil.key": Permission denied
I have tried all the recommended solutions to solve it, including changing the owner and group of the key to postgres. Nothing works. To verify that it doesn't work even with that, I ran the following command on the key:
sudo -u postgres cat ssl-cert-snakeoil.key
The result was:
cat: ssl-cert-snakeoil.key: Permission denied
(I am running Ubuntu 14.04 with Vagrant. Using passenger/ruby-20 image and Docker as provider.)
When using the 'postgresql' (https://supermarket.chef.io/cookbooks/postgresql) cookbook, chef-solo (v11.16.4) fails with:
Error executing action `enable` on resource 'service[postgresql]'
File '/etc/init/postgresql.conf' does not exist
This is because chef assumes that Linux Mint uses upstart; for the postgresql-9.3 package, it's still using init.d.
So the action [:enable]
attribute does the wrong thing.
(Originally reported as chef/chef#2726)
[2014-07-26T01:46:08+00:00] INFO: package[postgresql-server] installing postgresql-server-9.2.7-1.el7 from base repository
- install version 9.2.7-1.el7 of package postgresql-server
* template[/etc/sysconfig/pgsql/postgresql] action create[2014-07-26T01:46:19+00:00] INFO: Processing template[/etc/sysconfig/pgsql/postgresql] action create (postgresql::server_redhat line 54)
* Parent directory /etc/sysconfig/pgsql does not exist.
================================================================================
Error executing action `create` on resource 'template[/etc/sysconfig/pgsql/postgresql]'
================================================================================
Chef::Exceptions::EnclosingDirectoryDoesNotExist
------------------------------------------------
Parent directory /etc/sysconfig/pgsql does not exist.
Resource Declaration:
---------------------
# In /tmp/kitchen/cookbooks/postgresql/recipes/server_redhat.rb
54: template "/etc/sysconfig/pgsql/#{node['postgresql']['server']['service_name']}" do
55: source "pgsql.sysconfig.erb"
56: mode "0644"
57: notifies :restart, "service[postgresql]", :delayed
58: end
59:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cookbooks/postgresql/recipes/server_redhat.rb:54:in `from_file'
template("/etc/sysconfig/pgsql/postgresql") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
guard_interpreter :default
path "/etc/sysconfig/pgsql/postgresql"
backup 5
atomic_update true
source "pgsql.sysconfig.erb"
cookbook_name :postgresql
recipe_name "server_redhat"
mode "0644"
end
[2014-07-26T01:46:19+00:00] INFO: Running queued delayed notifications before re-raising exception
Running handlers:
[2014-07-26T01:46:19+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-07-26T01:46:19+00:00] ERROR: Exception handlers complete
[2014-07-26T01:46:19+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
Chef Client failed. 10 resources updated in 126.748339317 seconds
[2014-07-26T01:46:19+00:00] ERROR: template[/etc/sysconfig/pgsql/postgresql] (postgresql::server_redhat line 54) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/sysconfig/pgsql does not exist.
[2014-07-26T01:46:19+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
The attributes for this cookbook the client packages are neatly defined in attributes/default.rb. Why then is the "libpq-dev" package being explicitly installed in postgresql::ruby if it is already in the node['postgresql']['client']['packages'] list? This explicit installation causes that recipe to fail on Red Hat family distros since there is no "libpq-dev" package.
i have included this cookbook and get the following error message.
box OS is debian 7.3.
i only used the "postgresql_database_user" and "postgresql_database" resources
================================================================================
Error executing action `restart` on resource 'service[postgresql]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: Restarting PostgreSQL 9.1 database server: mainThe PostgreSQL server failed to start. Please check the log output: FATAL: unrecognized configuration parameter "host" ... failed!
failed!
STDERR:
---- End output of /etc/init.d/postgresql restart ----
Ran /etc/init.d/postgresql restart returned 1
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/postgresql/recipes/server_debian.rb
30: service "postgresql" do
31: service_name node['postgresql']['server']['service_name']
32: supports :restart => true, :status => true, :reload => true
33: action [:enable, :start]
34: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/postgresql/recipes/server_debian.rb:30:in `from_file'
service("postgresql") do
action [:enable, :start]
supports {:restart=>true, :status=>true, :reload=>true}
retries 0
retry_delay 2
service_name "postgresql"
enabled true
running true
pattern "postgresql"
startup_type :automatic
cookbook_name :postgresql
recipe_name "server_debian"
end
If this is an optional thing, how can I specify it? If it's not yet supported, any idea if this is in the Q1 2014 plans?
thanks for the amazing work on this project! It's projects like this that help a simpleton developer like me stay "full-stack-ish" :)
Since upgrading to Chef Client 11.14.2, the postgresql::ruby recipe fails to build for me (worked great yesterday on Chef Client 11.12.8).
It appears that the rescue clause in ruby.rb is looking for Gem::Installer::ExtensionBuildError during pg gem build, but on the new version of chef I'm seeing the error as Mixlib::ShellOut::ShellCommandFailed (see log below). Built fine in an identical EC2 environment and AMI with Chef Client 11.12.8. Under that version, the error threw ExtensionBuildError, which was caught and forced to build (second code snippet).
I've used the same run list with knife ec2 --bootstrap-version 11.12.8
and everything builds great on Ubuntu 14.04 (ami-dc5387bf).
Recipe: postgresql::ruby
* chef_gem[pg] action install
================================================================================
Error executing action `install` on resource 'chef_gem[pg]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:24:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/postgres.rb:13:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/default.rb:16:in `from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb
58: chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "pg"
version "0.17.1"
timeout 900
gem_binary "/opt/chef/embedded/bin/gem"
cookbook_name "postgresql"
recipe_name "ruby"
end
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/server-cookbook/recipes/default.rb
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
chef_gem[pg] (postgresql::ruby line 58) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:24:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/postgres.rb:13:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/default.rb:16:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:
51: end
52:
53: node['postgresql']['client']['packages'].each do |pg_pack|
54: resources("package[#{pg_pack}]").run_action(:install)
55: end
56:
57: begin
58>> chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
60: # Are we an omnibus install?
61: raise if RbConfig.ruby.scan(%r{(chef|opscode)}).empty?
62: # Still here, must be omnibus. Lets make this thing install!
63: Chef::Log.warn 'Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)'
64: gem_dir = e.message.scan(%r{will remain installed in ([^ ]+)}).flatten.first
65: raise unless gem_dir
66: gem_name = File.basename(gem_dir)
67: ext_dir = File.join(gem_dir, 'ext')
Running handlers:
[2014-08-02T00:45:04+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-08-02T00:45:04+00:00] ERROR: Exception handlers complete
[2014-08-02T00:45:04+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 13 resources updated in 120.81222453 seconds
[2014-08-02T00:45:04+00:00] ERROR: chef_gem[pg] (postgresql::ruby line 58) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" ----
Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.17.1" returned 1
[2014-08-02T00:45:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
--bootstrap-version
) Recipe: postgresql::ruby
* chef_gem[pg] action install
================================================================================
Error executing action `install` on resource 'chef_gem[pg]'
================================================================================
Gem::Installer::ExtensionBuildError
-----------------------------------
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:24:in `from_file'
/var/chef/cache/cookbooks/database/recipes/postgresql.rb:20:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/postgres.rb:13:in `from_file'
/var/chef/cache/cookbooks/server-cookbook/recipes/default.rb:16:in `from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb
58: chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "pg"
version "0.17.1"
cookbook_name "postgresql"
recipe_name "ruby"
end
[2014-08-01T16:07:14+00:00] WARN: Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)
* execute[generate pg gem Makefile] action run
- execute PATH=$PATH:/usr/pgsql-9.3/bin /opt/chef/embedded/bin/ruby extconf.rb
* execute[make pg gem lib] action run
- execute make
* execute[install pg gem lib] action run
- execute make install
* execute[install pg spec] action run
- execute /opt/chef/embedded/bin/gem spec ./cache/pg-0.17.1.gem --ruby > ./specifications/pg-0.17.1.gemspec
[2014-08-01T16:07:27+00:00] WARN: Installation of pg gem successful!
When I run the Postgresql server or ruby recipes on the prepackaged ubuntu/trusty64 Vagrant box from vagrant cloud, I get the following error:
Error executing action `install` on resource 'chef_gem[pg]'
===================
Gem::Installer::ExtensionBuildError
-----------------------------------
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:2:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
Cookbook Trace:
---------------
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
/tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:24:in `from_file'
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb
58: chef_gem "pg"
59: rescue Gem::Installer::ExtensionBuildError => e
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:58:in `rescue in from_file'
chef_gem("pg") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
package_name "pg"
version "0.17.1"
cookbook_name :postgresql
recipe_name "ruby"
end
One possible solution is described in http://blogs.law.harvard.edu/hoanga/2006/10/27/fixing-mkmf-load-error-ruby-in-ubuntu/. These are the important bits:
"If you’re a Debian or Ubuntu user you’ll find that the Ruby standard distribution is split into lots of little packages so doing something like apt-get install ruby only gives you the ruby binary and a subset of the libraries for Ruby. You’ll need to add more packages if you want to utilize more of Ruby’s standard library. This is all in order to comply with Debian packaging Guidelines."
...and...
"To get around [the mkmf error] you will need to install ruby1.8-dev (or ruby1.6-dev or whatever version of ruby you’re running) to get mkmf.rb which is listed in the Ruby Standard Library."
In other words, putting a sudo apt-get install ruby1.[version]-dev
in the Chef recipe might fix this bug.
Update: when running Chef on Ubuntu trusty, ruby 1.9.3 is what gets installed by default, but there is no ruby1.9.3-dev package in apt. Instead, you will actually need to obtain its alias, ruby1.9.1-dev, which http://askubuntu.com/questions/284459/couldnt-find-any-package-by-regex-ruby says will do what is needed.
Update: since the pg gem building happens before the convergence stage, this package must be installed at the recipe compilation stage or earlier.
Testing this cookbook with Test Kitchen (kitchen-vagrant driver), config_pgtune for "web" db_types sets the max_connections to 200. This causes PostgreSQL to fail to start.
Test by creating a blank cookbook and add a recipe with the following:
node.set[:postgresql][:config_pgtune][:db_type] = 'web'
include_recipe "postgresql::config_initdb"
include_recipe "postgresql::config_pgtune"
include_recipe "postgresql::server"
This bug was found using v3.4.10 of the postgresql cookbook.
On versions of postgres < 9.2 the following error occurs:
[2014-10-10T01:25:54+00:00] ERROR: service[postgresql](postgresql::server_debian line 26) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.1 database server
* The PostgreSQL server failed to start. Please check the log output:
FATAL: unrecognized configuration parameter "ssl_cert_file"
...fail!
STDERR:
---- End output of /etc/init.d/postgresql restart ----
Ran /etc/init.d/postgresql restart returned 1
For versions prior to 9.2, the expected behavior is to change a symlink in the $PGDATA path to point to the desired cert and key files. For versions 9.2 and later the expected behavior is to use the configuration parameter.
Here's the error:
Chef::Exceptions::Package ------------------------- package[libpq-dev] (postgresql::ruby line 50) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for libpq-dev ... Compiled Resource: ------------------ # Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/postgresql/recipes/ruby.rb:50:in `rescue in from_file' package("libpq-dev") do action [:nothing] retries 0 retry_delay 2 package_name "libpq-dev" cookbook_name :postgresql recipe_name "ruby" end
The package 'libpq-dev' does not exist in CentOS repositories. Apparently the package is called 'postgresql-libs'.
I was running 3.4.8 of the postgres cookbook on an ubuntu 14.04 vagrant virtualbox with chef-solo, it used to work on version 3.4.6 of the cookbook. I've attached the chef run output here: https://gist.github.com/Chili-Man/34b15891c12411a7c381
The reason it fails is because work_mem is set to 1, which when trying to load the postgres confirguration with that setting we get:
2014-10-07 16:38:25 GMT LOG: 1 is outside the valid range for parameter "work_mem" (64 .. 2147483647)
2014-10-07 16:38:25 GMT FATAL: configuration file "/etc/postgresql/9.3/main/postgresql.conf" contains errors
2014-10-07 16:38:25 GMT DEBUG: shmem_exit(1): 0 callbacks to make
2014-10-07 16:38:25 GMT DEBUG: proc_exit(1): 0 callbacks to make
2014-10-07 16:38:25 GMT DEBUG: exit(1)
The issue is in https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L197
the line should instead read:
if (con < mem)
Otherwise , under the condition mem < con
, when mem
is greater than con
, it will always set work_mem
to 1.
I instrumented that cookbook recipe to print out the variables and you can see output of it here:
https://gist.github.com/Chili-Man/f2b479c4a93c56bde55d
I added a few puts
above https://github.com/hw-cookbooks/postgresql/blob/master/recipes/config_pgtune.rb#L197 , that print mem
and con
:
PGSQL TUNE PARAMETERS
MEMORY: 3629
CONNECTIONS: 80
MEMORY LESS THAN CONNECTIONS: false
##################
postgresql::config_pgtune sets the shared_buffers setting in postgresql.conf to be a quarter of system ram, or sometimes one sixteenth of system ram. However, it does not change the kernel.shmmax value, which can cause Postgresql to fail to restart.
I'd like to upgrade Postgres from 9.1 to 9.3. I tried just setting the version for my node, but this installs them side-by-side rather than replacing the old one. How do I go about this? I'm running Ubuntu 12.04.
Thanks
I was having issues getting libpq-dev to install on Ubuntu14. Even after making sure to specify recipe[apt::default]
first in the run list. I noticed the ruby recipe (https://github.com/hw-cookbooks/postgresql/blob/develop/recipes/ruby.rb) was using run_action
and would to run before recipe[apt::default]
was being run.
This could be a odd use case as my base vagrant image already has the file /var/lib/apt/periodic/update-success-stamp
(last updated on July 6th) so the check being performed here https://github.com/hw-cookbooks/postgresql/blob/develop/recipes/ruby.rb#L32 was always skipping the apt-update
call from being triggered.
I added a quick work around for my situation here:
https://github.com/kpettijohn/postgresql/blob/feature/apt-update-on-time/recipes/ruby.rb#L33
Basically I just check that apt-get update
was run with 24 hours. I don't think this is really the best solution but I thought it would be worth creating a issue to give this some visibility if others run into the problem.
Starting Chef Client, version 11.14.2
resolving cookbooks for run list: ["apt::default", "mycookbook"]
Synchronizing Cookbooks:
- apt
- nginx
- beanstalkd
- bluepill
- ohai
- yum-epel
- database
- runit
- build-essential
- openssl
- rsyslog
- yum
- aws
- mysql-chef_gem
- chef-sugar
- mysql
- yum-mysql-community
- xfs
- mycookbook
- postgresql
Compiling Cookbooks...
Recipe: ohai::default
* remote_directory[/etc/chef/ohai_plugins for cookbook ohai] action create
- create new directory /etc/chef/ohai_plugins
- change mode from '' to '0755'
Recipe: <Dynamically Defined Resource>
* cookbook_file[/etc/chef/ohai_plugins/README] action create
- create new file /etc/chef/ohai_plugins/README
- update content in file /etc/chef/ohai_plugins/README from none to 775fa7
--- /etc/chef/ohai_plugins/README 2014-08-25 16:02:33.641378345 -0700
+++ /tmp/.README20140825-6943-3v6zpq 2014-08-25 16:02:34.033350556 -0700
@@ -1 +1,2 @@
+This directory contains custom plugins for Ohai.
- change mode from '' to '0644'
Recipe: ohai::default
* ohai[custom_plugins] action reload
- re-run ohai and merge results into node attributes
[2014-08-25T16:02:46-07:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2014-08-25T16:02:46-07:00] WARN: Previous service[nginx]: /home/vagrant/.chef/local-mode-cache/cache/cookbooks/nginx/recipes/package.rb:46:in `from_file'
[2014-08-25T16:02:46-07:00] WARN: Current service[nginx]: /home/vagrant/.chef/local-mode-cache/cache/cookbooks/nginx/recipes/default.rb:24:in `from_file'
Recipe: build-essential::_debian
* package[autoconf] action install (up to date)
* package[binutils-doc] action install (up to date)
* package[bison] action install (up to date)
* package[build-essential] action install (up to date)
* package[flex] action install (up to date)
* package[gettext] action install (up to date)
* package[ncurses-dev] action install (up to date)
Recipe: postgresql::apt_pgdg_postgresql
* file[remove deprecated Pitti PPA apt repository] action delete (up to date)
* apt_repository[apt.postgresql.org] action add
* remote_file[/home/vagrant/.chef/local-mode-cache/cache/ACCC4CF8.asc] action create (up to date)
* execute[install-key ACCC4CF8.asc] action run (skipped due to not_if)
* file[/var/lib/apt/periodic/update-success-stamp] action nothing (skipped due to action :nothing)
* execute[apt-cache gencaches] action nothing (skipped due to action :nothing)
* execute[apt-get update] action nothing (skipped due to action :nothing)
* file[/etc/apt/sources.list.d/apt.postgresql.org.list] action create (up to date)
(up to date)
Recipe: postgresql::client
* package[postgresql-client-9.3] action install (up to date)
* package[libpq-dev] action install
================================================================================
Error executing action `install` on resource 'package[libpq-dev]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '100'
---- Begin output of apt-get -q -y install libpq-dev=9.3.5-1.pgdg14.04+1 ----
STDOUT: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9
libkdb5-7 libpq5 libssl-dev libssl-doc zlib1g-dev
Suggested packages:
doc-base krb5-doc krb5-user postgresql-doc-9.3
The following NEW packages will be installed:
comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9
libkdb5-7 libpq-dev libssl-dev libssl-doc zlib1g-dev
The following packages will be upgraded:
libpq5
1 upgraded, 10 newly installed, 0 to remove and 2 not upgraded.
Need to get 2,032 kB/2,828 kB of archives.
After this operation, 11.4 MB of additional disk space will be used.
Err http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libssl-dev amd64 1.0.1f-1ubuntu2.4
404 Not Found [IP: 91.189.91.14 80]
Err http://security.ubuntu.com/ubuntu/ trusty-security/main libssl-dev amd64 1.0.1f-1ubuntu2.4
404 Not Found [IP: 91.189.92.201 80]
Err http://security.ubuntu.com/ubuntu/ trusty-security/main libssl-doc all 1.0.1f-1ubuntu2.4
404 Not Found [IP: 91.189.92.201 80]
STDERR: E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.0.1f-1ubuntu2.4_amd64.deb 404 Not Found [IP: 91.189.92.201 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-doc_1.0.1f-1ubuntu2.4_all.deb 404 Not Found [IP: 91.189.92.201 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
---- End output of apt-get -q -y install libpq-dev=9.3.5-1.pgdg14.04+1 ----
Ran apt-get -q -y install libpq-dev=9.3.5-1.pgdg14.04+1 returned 100
Cookbook Trace:
---------------
/home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/ruby.rb:54:in `block in from_file'
/home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/ruby.rb:53:in `each'
/home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/ruby.rb:53:in `rescue in from_file'
/home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/ruby.rb:24:in `from_file'
/home/vagrant/.chef/local-mode-cache/cache/cookbooks/mycookbook/recipes/default.rb:20:in `from_file'
Resource Declaration:
---------------------
# In /home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/client.rb
36: package pg_pack
37:
Compiled Resource:
------------------
# Declared in /home/vagrant/.chef/local-mode-cache/cache/cookbooks/postgresql/recipes/client.rb:36:in `block in from_file'
package("libpq-dev") do
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "libpq-dev"
version "9.3.5-1.pgdg14.04+1"
timeout 900
cookbook_name "postgresql"
recipe_name "client"
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.