Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load the app servers form the hosts data bag
Browse files Browse the repository at this point in the history
Sam Kottler committed Jul 19, 2014
1 parent d66fe85 commit 3ed4015
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Berksfile.lock
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ GRAPH
nginx (>= 0.0.0)
rubygems (>= 0.0.0)
rubygems-cloud-init (0.0.1)
rubygems-database (0.0.25)
rubygems-database (0.0.26)
chef-vault (>= 0.0.0)
database (>= 0.0.0)
postgresql (>= 0.0.0)
2 changes: 1 addition & 1 deletion cookbooks/rubygems-database/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name 'rubygems-database'
maintainer 'RubyGems.org ops team'

version '0.0.25'
version '0.0.26'

depends 'chef-vault'
depends 'database'
5 changes: 4 additions & 1 deletion cookbooks/rubygems-database/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -7,17 +7,20 @@
include_recipe 'chef-vault'

secrets = chef_vault_item('rubygems', node.chef_environment)
app_host = data_bag_item('hosts', 'application')['environments'][node.chef_environment]

node.default['postgresql']['config']['listen_addresses'] = '0.0.0.0'
node.default['postgresql']['config']['work_mem'] = '100MB'
node.default['postgresql']['config']['shared_buffers'] = '24MB'

# TODO: this needs to iterate over a list of application servers in the data
# bag.
node.default['postgresql']['pg_hba'] = [
{
'type' => 'host',
'db' => "rubygems_#{node.chef_environment}",
'user' => secrets['rails_postgresql_user'],
'addr' => "#{search('node', "name:app02.#{node.chef_environment}.rubygems.org")[0]['ipaddress']}/0",
'addr' => "#{search('node', "name:#{app_host}.#{node.chef_environment}.rubygems.org")[0]['ipaddress']}/0",
'method' => 'md5'
},
{
7 changes: 7 additions & 0 deletions data_bags/hosts/application.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "application",
"environments": {
"staging": "app01",
"production": "app02"
}
}

0 comments on commit 3ed4015

Please sign in to comment.