Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active April 9, 2016 02:46
Show Gist options
  • Save garystafford/8222755 to your computer and use it in GitHub Desktop.
Save garystafford/8222755 to your computer and use it in GitHub Desktop.
Gists for blogpost, 'Configure Chef on Windows for a Proxy Server': http://wp.me/p1RD28-11w. Settings for knife.rb file when using a proxy server from a Windows host. Set environment variables manually or use the Windows' command 'setx VARIABLE value'. You must close the current windows prompt and open a new one to see the SETX changes (env | gr…
# See http://docs.opscode.com/config_rb_knife.html
# for more information on knife configuration options
# Knife expects USERNAME, USERDNSDOMAIN, PASSWORD, PROXY_SERVER,
# and PROXY_PORT environment variables to be set at runtime.
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "chef_user_here"
client_key "#{ENV['HOME']}/.chef/chef_client_here.pem"
validation_client_name "organization_here-validator"
validation_key "#{ENV['HOME']}/.chef/organization_here-validator.pem"
chef_server_url "https://api.opscode.com/organizations/organization_here"
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path [ "#{ENV['HOME']}/path/to/your/cookbooks",
"#{ENV['HOME']}/other/path/to/your/cookbooks"
]
# comment below block when not behind proxy
#=begin
# proxy server settings
no_proxy ENV['NO_PROXY']
http_proxy ENV['HTTP_PROXY']
http_proxy_user ENV['USERNAME']
http_proxy_pass ENV['PASSWORD']
https_proxy ENV['HTTPS_PROXY']
https_proxy_user ENV['USERNAME']
https_proxy_pass ENV['PASSWORD']
# knife upload requires rest client proxy. Ignores above settings.
# install rest-client gem: gem install rest-client
# http://rubydoc.info/github/rest-client/rest-client
require 'rest-client'
RestClient.proxy = ENV['HTTP_PROXY']
#=end
@garystafford
Copy link
Author

Added support for knife upload from behind proxy. knife upload ignores http_proxy. See chef open tickets. Fix is to install rest-client gem and add above two lines to knife.rb file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment