Chef-client::config not reloading proxy config on first run


#1

Oh hai Chefs,

Was hoping someone might have the answer to a little problem we are having just now.

As part of our base role we include chef-client::config and configure interval, http_proxy and no_proxy via role default attributes.

We are behind a proxy so we have to configure http_proxy as well as no_proxy set to our IP range as well as localhost (that was fun to work out that you needed to specify localhost in no_proxy unless you wanted chef-client to try to use the proxy for that… but thats another matter…).

The issue is that chef-client::config is that the proxy settings don’t seem to reload and take effect in the first run. On first run when a cookbook tries to reach an external file, for example the opscode repo key as part of an apt_repository provider call, it will get refused connection and cause the run to fail. A subsequent second run, with no changes, will be successful. (The client.rb file is set correctly during the first run.)

Whilst we can just run chef-client twice when we provision a new VM, its not ideal…

Sample log output below. Any help would be appreciated.

Regards,
Gavin

first run:

[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/run/chef] action create (chef-client::config line 31)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: directory[/var/run/chef] created directory /var/run/chef
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/cache/chef] action create (chef-client::config line 31)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: directory[/var/cache/chef] created directory /var/cache/chef
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/lib/chef] action create (chef-client::config line 31)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: directory[/var/lib/chef] created directory /var/lib/chef
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/log/chef] action create (chef-client::config line 31)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: directory[/var/log/chef] created directory /var/log/chef
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing template[/etc/chef/client.rb] action create (chef-client::config line 39)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/chef/client.rb] backed up to /var/chef/backup/etc/chef/client.rb.chef-20120813163953
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/chef/client.rb] mode changed to 644
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/chef/client.rb] updated content
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing ruby_block[reload_client_config] action nothing (chef-client::config line 48)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/run/chef] action create (chef-client::service line 42)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/cache/chef] action create (chef-client::service line 42)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/lib/chef] action create (chef-client::service line 42)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing directory[/var/log/chef] action create (chef-client::service line 42)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing template[/etc/init.d/chef-client] action create (chef-client::service line 61)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/init.d/chef-client] mode changed to 755
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/init.d/chef-client] updated content
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing template[/etc/default/chef-client] action create (chef-client::service line 70)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/default/chef-client] mode changed to 644
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/default/chef-client] updated content
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: template[/etc/default/chef-client] not queuing delayed action restart on service[chef-client] (delayed), as it’s already been queued
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: Processing service[chef-client] action enable (chef-client::service line 76)
[Mon, 13 Aug 2012 16:39:53 +0100] INFO: service[chef-client] enabled


[Mon, 13 Aug 2012 16:39:57 +0100] INFO: Processing remote_file[/var/chef/cache/packages@opscode.com.gpg.keymailto:var/chef/cache/packages@opscode.com.gpg.key] action create (/var/chef/cache/cookbooks/apt/providers/repository.rb line 36)
[Mon, 13 Aug 2012 16:39:57 +0100] ERROR: Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, retry 1/5
[Mon, 13 Aug 2012 16:40:02 +0100] ERROR: Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, retry 2/5
[Mon, 13 Aug 2012 16:40:07 +0100] ERROR: Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, retry 3/5
[Mon, 13 Aug 2012 16:40:12 +0100] ERROR: Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, retry 4/5
[Mon, 13 Aug 2012 16:40:17 +0100] ERROR: Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, retry 5/5


[Mon, 13 Aug 2012 16:40:22 +0100] FATAL: Errno::ECONNREFUSED: apt_repository[opscode] (repositories::default line 14) had an error: Errno::ECONNREFUSED: remote_file[/var/chef/cache/packages@opscode.com.gpg.keymailto:var/chef/cache/packages@opscode.com.gpg.key] (/var/chef/cache/cookbooks/apt/providers/repository.rb line 36) had an error: Errno::ECONNREFUSED: Connection refused - Connection refused connecting to apt.opscode.comhttp://apt.opscode.com:80 for /packages@opscode.com.gpg.keymailto:packages@opscode.com.gpg.key, giving up

second run: log entries show it successfully retrieves the key and run completes as normal without error

Gavin Reynolds
SRC IT Support
University of Glasgow Students’ Representative Council

e: g.reynolds@src.gla.ac.ukmailto:g.reynolds@src.gla.ac.uk
t: 0141 339 8541
f: 0141 337 3557
w: www.glasgowstudent.nethttp://www.glasgowstudent.net

The University of Glasgow Students’ Representative Council is a charity
registered in Scotland. Registration number SC006970