Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
[COOK-513] chef-client cookbook improvements
Browse files Browse the repository at this point in the history
* ability to set the http_proxy values via a node attribute
* create all backup/cache directories incase they change mid chef run (will prevent bug found in CHEF-2256)
  • Loading branch information
schisamo committed Apr 22, 2011
1 parent 01b43cb commit b5bec93
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
16 changes: 14 additions & 2 deletions chef-client/README.md
Expand Up @@ -111,9 +111,20 @@ The default Chef Server will be `http://localhost:4000` which is the `Chef::Conf
"validation_client_name" => "ORGNAME-validator"
}
)

Where ORGNAME is your Opscode Platform organization name. Be sure to add these attributes to the role if modifying per the section below.

You can also set all of the `Chef::Config` http proxy related settings. By default Chef will not use a proxy.

override_attributes(
"chef_client" => {
"http_proxy" => "http://proxy.vmware.com:3128",
"https_proxy" => "http://proxy.vmware.com:3128",
"http_proxy_user" => "my_username",
"http_proxy_pass" => "Awe_some_Pass_Word!",
"no_proxy" => "*.vmware.com,10.*"
}
)

Alternate Init Styles
---------------------

Expand Down Expand Up @@ -218,7 +229,8 @@ LICENSE AND AUTHORS
===================

* Author: Joshua Timberman <joshua@opscode.com>
* Copyright 2010, Opscode, Inc.
* Author: Seth Chisamore <schisamo@opscode.com>
* Copyright 2010-2011, Opscode, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion chef-client/metadata.rb
Expand Up @@ -3,7 +3,7 @@
license "Apache 2.0"
description "Manages aspects of only chef-client"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.99.4"
version "0.99.5"
recipe "chef-client", "Includes the service recipe by default."
recipe "chef-client::config", "Configures the client.rb from a template."
recipe "chef-client::service", "Sets up a client daemon to run periodically"
Expand Down
9 changes: 9 additions & 0 deletions chef-client/recipes/config.rb
Expand Up @@ -26,6 +26,15 @@

chef_node_name = Chef::Config[:node_name] == node["fqdn"] ? false : Chef::Config[:node_name]

%w{run_path cache_path backup_path log_dir}.each do |key|
directory node['chef_client'][key] do
recursive true
owner "root"
group root_group
mode 0755
end
end

template "/etc/chef/client.rb" do
source "client.rb.erb"
owner "root"
Expand Down
13 changes: 13 additions & 0 deletions chef-client/templates/default/client.rb.erb
Expand Up @@ -15,6 +15,19 @@ node_name "<%= @chef_node_name %>"

file_backup_path "<%= node["chef_client"]["backup_path"] %>"
file_cache_path "<%= node["chef_client"]["cache_path"] %>"

<% unless %w{ runit bluepill daemontools }.include?(node["chef_client"]["init_style"]) -%>
pid_file "<%= node["chef_client"]["run_path"] %>/client.pid"
<% end -%>
<%= "http_proxy \"#{node["chef_client"]["http_proxy"]}\"\n" unless node["chef_client"]["http_proxy"].nil? -%>
<%= "https_proxy \"#{node["chef_client"]["https_proxy"]}\"\n" unless node["chef_client"]["https_proxy"].nil? -%>
<%= "http_proxy_user \"#{node["chef_client"]["http_proxy_user"]}\"\n" unless node["chef_client"]["http_proxy_user"].nil? -%>
<%= "http_proxy_pass \"#{node["chef_client"]["http_proxy_pass"]}\"\n" unless node["chef_client"]["http_proxy_pass"].nil? -%>
<%= "no_proxy \"#{node["chef_client"]["no_proxy"]}\"\n" unless node["chef_client"]["no_proxy"].nil? -%>
<% unless node["chef_client"]["http_proxy"].nil? -%>
# set the proxy env variable so rubygems works correctly
ENV['http_proxy'] = "<%= node["chef_client"]["http_proxy"] %>"
ENV['HTTP_PROXY'] = "<%= node["chef_client"]["http_proxy"] %>"
<% end -%>

0 comments on commit b5bec93

Please sign in to comment.