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

Commit

Permalink
Load the app servers form the hosts data bag
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Kottler committed Jul 19, 2014
1 parent d66fe85 commit 3ed4015
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Berksfile.lock
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/rubygems-database/metadata.rb
@@ -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'
Expand Down
5 changes: 4 additions & 1 deletion cookbooks/rubygems-database/recipes/default.rb
Expand Up @@ -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'
},
{
Expand Down
7 changes: 7 additions & 0 deletions data_bags/hosts/application.json
@@ -0,0 +1,7 @@
{
"id": "application",
"environments": {
"staging": "app01",
"production": "app02"
}
}

0 comments on commit 3ed4015

Please sign in to comment.