Using database cookbook behind a proxy (require 'pg')

Hi all,
we are trying to use database cookbook, but our node is behind a proxy
and we cannot manage how to force chef to use gem with proxy setup.

As written here:

"The providers use specific Ruby gems installed under Chef's Ruby
environment to execute commands and carry out actions. These gems will
need to be installed before the providers can operate correctly.
...
PostgreSQL: leverages the pg gem which is installed as part of the
postgresql::ruby recipe. You can use database::postgresql to include
this, too."

As you can see, here is the error that breaks chef run (confirmed by netstat):

MYNODE_LOG Recipe: postgresql::ruby
MYNODE_LOG * chef_gem[pg] action install
MYNODE_LOG [2013-05-06T17:16:45+02:00] INFO: Processing chef_gem[pg]
action install (postgresql::ruby line 40)
MYNODE_LOG WARNING: Error fetching data: Errno::ETIMEDOUT: Connection
timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)

We also tried setting up /etc/gemrc in this way:
gem: --http-proxy=http://MYPROXY

and, while it woks calling gem directly, it is ignored during chef run.

Also our /etc/chef/client.rb is correctly configured:
log_level :auto
...
http_proxy "http://MYPROXY"
https_proxy "http://MYPROXY"

Any help would be appreciated :slight_smile:

Many thanks,
Marco

You using omnibus chef-client? gemrc should work, you just have to put in a
different file - /opt/chef/embedded/etc/gemrc maybe? ~root/.gemrc may work
as well.

Thanks for the advice, but it still doesn't work also setting both
/opt/chef/embedded and ~root/.gemrc

Yes, it is an omnibus installation.

This is a big problem for us... is there any other organization using
database cookbook with proxy for http/s connection?

Regards,
Marco

On Tue, May 7, 2013 at 1:47 AM, Brian Akins brian@akins.org wrote:

You using omnibus chef-client? gemrc should work, you just have to put in
a different file - /opt/chef/embedded/etc/gemrc maybe? ~root/.gemrc may
work as well.

problem solved using Ruby’s predefined ENV variable to set the environment
variable http_proxy (well understood by gem install) in a wrapper recipe
that calls:

ENV['HTTP_PROXY'] = "myproxy"
include_recipe "postgresql::ruby"

Marco

On Thu, May 23, 2013 at 7:38 PM, Marco Betti m.betti@gmail.com wrote:

Thanks for the advice, but it still doesn't work also setting both
/opt/chef/embedded and ~root/.gemrc

Yes, it is an omnibus installation.

This is a big problem for us... is there any other organization using
database cookbook with proxy for http/s connection?

Regards,
Marco

On Tue, May 7, 2013 at 1:47 AM, Brian Akins brian@akins.org wrote:

You using omnibus chef-client? gemrc should work, you just have to put in
a different file - /opt/chef/embedded/etc/gemrc maybe? ~root/.gemrc may
work as well.