Coder Social home page Coder Social logo

coroutine / chef-postgresql Goto Github PK

View Code? Open in Web Editor NEW
43.0 15.0 24.0 245 KB

This is a fork of the Opscode PostgreSQL cookbook, which as been modified to install PostgresQL 9.1 on ubuntu (10.04) as well as support for synchronous replication and hot standby.

License: Apache License 2.0

Ruby 100.00%

chef-postgresql's Introduction

Description

This is a fork of the Opscode PostgreSQL cookbook, which has been modified extensively.

  • Adds support for PostgresQL 9.1 on Ubuntu 10.04 (Lucid) using a PPA.
  • Adds a recipe to create PostgreSQL user accounts and databases (this particular addition couples this to the database cookbook)
  • Adds support for configuring Hot Standby with Streaming replication (optionally synchronous) in PostgreSQL 9.1

TODO: while hot-standby is configured, there's nothing in postgresql that'll do automated failover if the master dies. Typically, that's accomplished by:

  • touching a trigger file on the standby (it'll then act as a master)
  • using some form of IP failover so the Master's IP address is automatically transferred to the standby
  • some STONITH mechanism for the old master, so it doesn't come back online

None of the above are handled automatically in this cookbook.

Requirements

Platforms

  • Debian, Ubuntu
  • Red Hat/CentOS/Scientific (6.0+ required) - "EL6-family"
  • Fedora
  • SUSE

Note: Hot Standby and Streaming replication are only supported on Debian and Ubuntu.

Cookboooks

Requires Opscode's openssl cookbook for secure password generation, and a C compiler and development headers in order to build the pg RubyGem to provide Ruby bindings so they're available in other cookbooks.

Opscode's build-essential cookbook provides this functionality on Debian, Ubuntu, and EL6-family.

While not required, Opscode's database cookbook contains resources and providers that can interact with a PostgreSQL database. The Opscode postgresqlcookbook is a dependency of database.

Attributes

The following attributes are set based on the platform, see the attributes/default.rb file for default values.

  • node['postgresql']['version'] - version of postgresql to manage
  • node['postgresql']['dir'] - home directory of where postgresql data and configuration lives.
  • node['postgresql']['client']['packages'] - An array of package names that should be installed on "client" systems.
  • node['postgresql']['server']['packages'] - An array of package names that should be installed on "server" systems.

The following attributes are generated in recipe[postgresql::server].

  • node['postgresql']['password']['postgres'] - randomly generated password by the openssl cookbook's library.
  • node['postgresql']['ssl'] - whether to enable SSL (off for version 8.3, true for 8.4 and later).
  • For SSL keys to be automatically generated for you, you need to override node[:postgresql][:ssl_password] (only tested on Ubuntu). This password is the passphrase used for signing the certificates.

The following attributes are used by the setup recipe:

  • node['postgresql']['databag'] - the data bag in which the setup recipe searches for items. Default is postgresql
  • node['postgresql']['setup_items'] - a list of data bag items containing user/database information. See the notes for the setup recipe for the expected format.

There are also a number of other attributes defined that control things such as host based access (pg_hba.conf) and hot standby. A few are listed below, but see attributes/default.rb for more information.

  • node['postgresql']['hba'] - a list of address/method hashes defining the ip address that will be able to connect to PostreSQL

Streaming Replication

The following attributes can be modified to enable and configure streaming replication and for a Master or Standby.

  • default[:postgresql][:listen_addresses]
  • default[:postgresql][:master] - Whether a node is a master. Defaults to false. In this case, replication will not be configured, and the rest of the master settings will be ignored.
  • default[:postgresql][:standby] - Whether a node is a standby. Defaults to false. In this case, replication will not be configured, and the rest of the standby settings will be ignored.

Master Server

  • default[:postgresql][:wal_level] - set to hot_standby to enable Hot standby.
  • default[:postgresql][:max_wal_senders]
  • default[:postgresql][:wal_sender_delay]
  • default[:postgresql][:wal_keep_segments]
  • default[:postgresql][:vacuum_defer_cleanup_age]
  • default[:postgresql][:replication_timeout]
  • default[:postgresql][:synchronous_standby_names] - If you want synchronous replication, this must be a string containing a comma-separated list of node names of the standby servers.
  • default[:postgresql][:standby_ips] - A list of IP addresses for standbys. These MUST be specified in a role.

Standby Servers

  • default[:postgresql][:master_ip] - This MUST Be specified in the role. It lets the standby know how to connect to the master.
  • default[:postgresql][:hot_standby] - set to on to enable hot standby.
  • default[:postgresql][:max_standby_archive_delay]
  • default[:postgresql][:max_standby_streaming_delay]
  • default[:postgresql][:wal_receiver_status_interval]
  • default[:postgresql][:hot_standby_feedback]

Recipes

default

This recipe just includes the postgresql::client recipe, which installs the postgresql client package and required dependencies.

apt_postgresql_ppa

Adds sources for a PosgresSQL 9.1 package for Ubuntu 10.04. NOTE that this recipe should only be used in Ubuntu 10.04. Newer versions of Ubuntu include PostgreSQL 9.1 in their package repository.

To use this, you'll need to specify the PostgreSQL version and dir attributes. For example, add the folloing to your role:

override_attributes(
  :postgresql => {
    :version => "9.1",
    :dir => "/etc/postgresql/9.1/main"  
  }
) 

client

Installs postgresql client packages and development headers during the compile phase.

ruby

NOTE This recipe may not currently work when installing Chef with the "Omnibus" full stack installer on some platforms due to an incompatibility with OpenSSL. See COOK-1406

Install the pg gem under Chef's Ruby environment so it can be used in other recipes.

server

Includes the server_debian or server_redhat recipe to get the appropriate server packages installed and service managed. Also manages the configuration for the server:

  • generates a strong default password (via openssl) for postgres
  • sets the password for postgres
  • manages the pg_hba.conf file.

server_debian

Installs the postgresql server packages, manages the postgresql service and the postgresql.conf file.

server_redhat

Manages the postgres user and group (with UID/GID 26, per RHEL package conventions), installs the postgresql server packages, initializes the database and manages the postgresql service, and manages the postgresql.conf file.

setup

Creates Roles (user account) and Databases from a data bag. See the Usage section for more info.

Resources/Providers

See the database for resources and providers that can be used for managing PostgreSQL users and databases.

Usage

On systems that need to connect to a PostgreSQL database, add to a run list recipe[postgresql] or recipe[postgresql::client].

On systems that should be PostgreSQL servers, use recipe[postgresql::server] in a run list. This recipe does set a password and expect to use it. It performs a node.save when Chef is not running in solo mode. If you're using chef-solo, you'll need to set the attribute node['postgresql']['password']['postgres'] in your node's json_attribs file or in a role.

Streaming Replication/Hot Standby

To set this up, you'd need to:

  1. Bootstrap the Nodes (you've got know know their IP addresses!)
  2. Assign the server recipe to the master and slave nodes to install a standard postgresql server.
  3. Log into the Standby machine and shut down PostgreSQL.
  4. Create the Master/Standby Roles (see below) and apply to each node. * Make sure both nodes have access to each others' PostgreSQL service by adding the appropriate values for the node['postgresql']['hba'] attribute.
  5. Run chef-client on the Master. Wait for it to finish.
  6. Run chef-client on the Standby. It will fail. That's ok. Log into the standby and make sure PostgreSQL is not running.
  7. Log into the master and manually remove /var/lib/postgresql/9.1/main/.initial_transfer_complete, then re-run chef-client (it will again copy the database data directory over to the standby via rsync, so you'll be prompted for a password unless you've got public keys in place... make sure this step works!)
  8. Restart postgresql on the master, then on the standby and run chef-client on both nodes. Check to make sure PostgreSQL's sender and receiver processes are running:
    • Run ps -ef | grep sender on the Master
    • Run ps -ef | grep receiver on the Standby
  9. Subsequent runs of chef-client should work without any errors.

Master Role

To configure a Master server, you would need to create a role that sets the appropriate properties. For example, given that you have a node namded db2 with an ip address of 10.0.0.11, you might create a role similar to the one below:

name "pg_server_master"
description "A PostgreSQL Master"
run_list "recipe[postgresql::server]"

override_attributes(
  :postgresql => {
    :version => "9.1",
    :dir => "/etc/postgresql/9.1/main",
    :master => true,
    :listen_addresses => "*",
    :wal_level => "hot_standby",
    :max_wal_senders => 5,
    :standby_ips => [ "10.0.0.11", ],
    :synchronous_standby_names => ["db2", ], # Omit this if you don't want
                                             # synchronous replication
    :hba => [
        { :method => 'md5', :address => '127.0.0.1/32' },
        { :method => 'md5', :address => '::1/128' },
        { :method => 'md5', :address => '10.0.0.10' },
        { :method => 'md5', :address => '10.0.0.11' },
    ]
  }
)

Standby Role

To configure a Standby, you could create a similar role. Assuming the master was available at an ip address of 10.0.0.10:

name "pg_server_standby"
description "A PostgreSQL Standby"
run_list "recipe[postgresql::server]"

override_attributes(
  :postgresql => {
    :version => "9.1",
    :dir => "/etc/postgresql/9.1/main",
    :standby => true,
    :hot_standby => "on",
    :master_ip => "10.0.0.10",
    :hba => [
        { :method => 'md5', :address => '127.0.0.1/32' },
        { :method => 'md5', :address => '::1/128' },
        { :method => 'md5', :address => '10.0.0.10' },
        { :method => 'md5', :address => '10.0.0.11' },
    ]
  }
)

User/Database Setup

To configure users and databases, create a data bag with the name used in the default[:postgresql][:databag] attribute. Items in this databag will be used to create both PostgreSQL users and databases. The format of each databag item should be similar to the following:

{
   "id": "sample_db_setup",
   "users": [
       {
           "username":"some_user",
           "password":"some_password",
           "superuser": "true",
       }
   ],
   "databases": [
       {
           "name":"some_db",
           "owner":"some_user", 
           "template":"template0",
           "encoding": "UTF8",
           "locale": "en_US.utf8"
       }
   ] 
}

Then, override the node['postgresql']['setup_items'] attribute in a role:

override_attributes(
  :postgresql => {
    :databag     => "postgresql", # databag from which items are fetched
    :setup_items => ["sample_db_setup", ]  # name of item from which
                                           # user/database info is read.
  }
)

License and Author

Author:: Joshua Timberman ([email protected]) Author:: Lamont Granquist ([email protected]) Author:: Brad Montgomery ([email protected])

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

chef-postgresql's People

Contributors

astratto avatar bradmontgomery avatar brynary avatar btm avatar chewi avatar fnichol avatar gregkare avatar lispython avatar nathenharvey avatar ramontayag avatar sfiggins avatar soffes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-postgresql's Issues

Not working with librarian-chef

When I try to add the cookbook via librarian I get an error:

Cheffile:

#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

cookbook 'apt', :git => 'https://github.com/fnichol/chef-apt'
cookbook 'git', :git => 'https://github.com/fnichol/chef-git.git'
cookbook 'build-essential'
cookbook 'rvm', :git => 'git://github.com/fnichol/chef-rvm.git'
cookbook 'memcached'
cookbook 'postgresql', :git => 'https://github.com/coroutine/chef-postgresql.git'
cookbook 'mysql'
cookbook 'vim'

Error:

dickeyxxx@dickey-mbp ~/proj/tapjoymarketplace 1.9.3-p194 (mystique ✘)✖✹ ⇪
✗✗✗ librarian-chef install
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:153:in `tsort_each': topological sort failed: ["database", "postgresql"] (TSort::Cyclic)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:184:in `each_strongly_connected_component'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:220:in `each_strongly_connected_component_from'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:183:in `each_strongly_connected_component'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:181:in `tsort_each_node'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:181:in `each_strongly_connected_component'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:149:in `tsort_each'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/tsort.rb:136:in `tsort'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/manifest_set.rb:31:in `sort'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/resolver.rb:69:in `sort'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/resolver.rb:21:in `resolve'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/action/resolve.rb:25:in `run'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/cli.rb:164:in `resolve!'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/chef/cli.rb:41:in `install'
    from /Library/Ruby/Gems/1.8/gems/thor-0.15.4/lib/thor/task.rb:27:in `send'
    from /Library/Ruby/Gems/1.8/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
    from /Library/Ruby/Gems/1.8/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
    from /Library/Ruby/Gems/1.8/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
    from /Library/Ruby/Gems/1.8/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/lib/librarian/cli.rb:33:in `bin!'
    from /Library/Ruby/Gems/1.8/gems/librarian-0.0.24/bin/librarian-chef:7
    from /usr/bin/librarian-chef:19:in `load'
    from /usr/bin/librarian-chef:19

Not sure if I should post that here or with librarian, but it seems to be an issue with this repo as the opscode version of the cookbook works fine, but this does not.

Can this be shared upstream with opscode-cookbooks/postgresql?

This is a big improvement on the original opscode-cookbooks/postgresql, with your approach to PostgreSQL 9.X support with installing from alternate repositories, configuring for replication, etc. It looks like you may have forked in Febrary 2012,shortly after they declared v0.99.2. The OpsCode cookbook was recently declared release v2.0.2. Both projects have changed considerably, but I haven't looked at the OpsCode version in many months.

Template failure on 12.04

We're attempting a build of this cookbook onto a new EC2 server (12.04), using the recipes "apt_postgres_ppa", and "server_debian". This process seems to fail with a template file error. Being a chef newb, I'm unsure how to properly debug further.

Error Log:

[Wed, 16 May 2012 23:27:38 +0000] INFO: Processing template[/etc/postgresql/9.1/main/postgresql.conf] action create (chef-postgresql::server_debian line 67)
[Wed, 16 May 2012 23:27:38 +0000] INFO: template[/etc/postgresql/9.1/main/postgresql.conf] owner changed to 106
[Wed, 16 May 2012 23:27:38 +0000] INFO: template[/etc/postgresql/9.1/main/postgresql.conf] group changed to 113
[Wed, 16 May 2012 23:27:38 +0000] ERROR: template[/etc/postgresql/9.1/main/postgresql.conf](chef-postgresql::server_debian line 67) has had an error
[Wed, 16 May 2012 23:27:38 +0000] ERROR: template/etc/postgresql/9.1/main/postgresql.conf had an error:
template[/etc/postgresql/9.1/main/postgresql.conf](chef-postgresql::server_debian line 67) had an error: Errno::ENOENT: No such file or directory - /tmp/chef-rendered-template20120516-19892-k62v2c-0 or /etc/postgresql/9.1/main/postgresql.conf
/usr/lib/ruby/1.8/fileutils.rb:506:in 'rename'
/usr/lib/ruby/1.8/fileutils.rb:506:in 'mv'
...
/usr/local/bin/chef-client:19
[Wed, 16 May 2012 23:27:38 +0000] ERROR: Running exception handlers
[Wed, 16 May 2012 23:27:39 +0000] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[Wed, 16 May 2012 23:27:39 +0000] ERROR: Exception handlers complete
[Wed, 16 May 2012 23:27:39 +0000] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[Wed, 16 May 2012 23:27:39 +0000] FATAL: Errno::ENOENT: template[/etc/postgresql/9.1/main/postgresql.conf](chef-postgresql::server_debian line 67) had an error: Errno::ENOENT: No such file or directory - /tmp/chef-rendered-template20120516-19892-k62v2c-0 or /etc/postgresql/9.1/main/postgresql.conf

Error: Invalid data directory: Restarting PostgreSQL 9.1 database server

ubuntu precise 12.04.2 in vagrant
this portgresql cookbook

[2013-02-24T16:08:48+00:00] INFO: template[/etc/postgresql/9.1/main/postgresql.conf] sending restart action to service[postgresql] (delayed)
[2013-02-24T16:08:48+00:00] INFO: Processing service[postgresql] action restart (postgresql::server_debian line 67)


================================================================================

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
 * Error: Invalid data directory
   ...fail!
STDERR:
---- End output of /etc/init.d/postgresql restart ----
Ran /etc/init.d/postgresql restart returned 1




Resource Declaration:

---------------------

# In /srv/chef/file_store/cookbooks/postgresql/recipes/server_debian.rb

 67: service "postgresql" do
 68:   case node['platform']
 69:   when "ubuntu"
 70:     case
 71:     # PostgreSQL 9.1 on Ubuntu 10.04 gets set up as "postgresql", not "postgresql-9.1"
 72:     # Is this because of the PPA? And is this still the case?
 73:     when node['platform_version'].to_f <= 10.04 && node['postgresql']['version'].to_f < 9.0
 74:       service_name "postgresql-#{node['postgresql']['version']}"
 75:     else
 76:       service_name "postgresql"
 77:     end
 78:   when "debian"





Compiled Resource:

------------------

# Declared in /srv/chef/file_store/cookbooks/postgresql/recipes/server_debian.rb:67:in `from_file'

service("postgresql") do
  action [:nothing]
  updated true
  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





[2013-02-24T16:08:49+00:00] INFO: template[nginx.conf] sending reload action to service[nginx] (delayed)
[2013-02-24T16:08:49+00:00] INFO: Processing service[nginx] action reload (rails-lastmile::default line 71)
[2013-02-24T16:08:49+00:00] INFO: service[nginx] reloaded
[2013-02-24T16:08:49+00:00] INFO: template[/etc/nginx/sites-enabled/default] sending restart action to service[nginx] (delayed)
[2013-02-24T16:08:49+00:00] INFO: Processing service[nginx] action restart (rails-lastmile::default line 71)
[2013-02-24T16:08:51+00:00] INFO: service[nginx] restarted
[2013-02-24T16:08:51+00:00] ERROR: Running exception handlers
[2013-02-24T16:08:51+00:00] FATAL: Saving node information to /srv/chef/file_store/failed-run-data.json
[2013-02-24T16:08:51+00:00] ERROR: Exception handlers complete
[2013-02-24T16:08:51+00:00] FATAL: Stacktrace dumped to /srv/chef/file_store/chef-stacktrace.out
[2013-02-24T16:08:51+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: service[postgresql] (postgresql::server_debian line 67) 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
 * Error: Invalid data directory
   ...fail!
STDERR:
---- End output of /etc/init.d/postgresql restart ----
Ran /etc/init.d/postgresql restart returned 1
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

chef-client -c /tmp/vagrant-chef-1/client.rb -j /tmp/vagrant-chef-1/dna.json

error creating pg_hba.conf Chef::Mixin::Template::TemplateError:

Thanks for nice cookbook for postgres. I tried but ran into an error creating pg_hba.conf using template. Wonder where its going wrong.

vagrant@precise64:~$ cat /srv/chef/file_store/chef-stacktrace.out

Generated at Sun Feb 17 06:48:22 +0000 2013
Chef::Mixin::Template::TemplateError:

Chef::Mixin::Template::TemplateError (undefined method `keys' for #<Array:0x7f7fc9b75750>) on line #7:

  5:
  6: # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
  7: <% node['postgresql']['pg_hba'].each do |auth| -%>
  8: <%= auth[:type] %>  <%= auth[:db] %>  <%= auth[:user] %>  <%= auth[:addr] %>  <%= auth[:method] %>
  9: <% end -%>

  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/node/attribute.rb:250:in `keys'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/node/attribute.rb:248:in `each'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/node/attribute.rb:248:in `keys'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/node/attribute.rb:243:in `get_keys'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/node/attribute.rb:129:in `each'
  (erubis):7:in `evaluate'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/template.rb:41:in `render_template'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider/template.rb:104:in `render_with_context'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider/template.rb:50:in `action_create'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider.rb:119:in `send'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider.rb:119:in `run_action'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource.rb:593:in `run_action'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:49:in `run_action'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `converge'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `each'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `converge'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection.rb:94:in `execute_each_resource'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:80:in `converge'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:378:in `converge'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:420:in `do_run'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/client.rb:283:in `run_application'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/client.rb:270:in `loop'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/client.rb:270:in `run_application'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
  /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-client:26
  /opt/vagrant_ruby/bin/chef-client:19:in `load'
  /opt/vagrant_ruby/bin/chef-client:19

These are the override attributes.


override_attributes(

  :authorization => {
    :sudo => {
      :users => ["ubuntu", "vagrant"],
      :passwordless => true
    }
  },

  :'rails-lastmile' => {
      :'app_dir' => "/home/vagrant/proj-name",
      :'ruby_version' => "1.9.3-p385"
  },

  :postgresql => {
      :databag     => "postgresql", # databag from which items are fetched
      :setup_items => ["sample_db_setup", ],  # name of item from which
                                             # user/database info is read.
      :'pg_hba' => {:type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'md5'}                                       
  }
)

Installing more than 1 db

How do you create more than one database? I tried the following:

https://gist.github.com/a95b97b53cf9665eae0c

The first file is the databag. The second one is where I override the attributes. This is my best guess. However, only the sillauctions database is being created. When I do psql --list | grep labada on the server, there is no result.

Is there something wrong I'm doing? I can add this to the readme. :)

data_bags example?

I'm new to the postgresql recipe and found the part about "data_bags" confusing in the readme. Could you provide a simple example to help new devs get this working?

In particular ...

1.) can I declare this inline (just under the root "postgres" element with a attr of "data_bags"? If so what does the final config look like for a basic -create a 9.1 setup w/ 1 user and 1 database?

2.) if you cannot declare this inline, how do you do the "data_bags" directory setup so the recipe picks it up during the runtime?

ie- is this a simple mkdir in the root of your chef-solo project for a dir "data_bags"

if so what naming conventions follow? ie- do I need a folder named "postgresql" and if so what goes under it? what do I name the json file that has the users and databases? can they both live in 1 json file or do I need multiple?

I'm kicking this off from my main cookbook as follows

"postgresql::server"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.