2011年8月17日水曜日

proxy setting for chef (knife)

I wanted to use knife commands to download and upload to chef hosts.

My chef version is 0.10.4.

1. Add "http_proxy", "https_proxy" to knife.rb. Only "http_proxy" will not do. Need both.
   See if knife works with "knife node list"
2. The above will do for just download but doesn't work for uploads.
   You will need to add" require 'rest-client'" and RestClient.proxy = "http://yourproxyserver:port"
   Test by "knife cookbook upload xxxxx"

Also, be sure to have ruby version 1.8.7 or above because uploading will not work with 1.8.6.
Because chef uses ruby's "tap" method and it is supported from 1.8.7.













**My knife.rb example************************





current_dir = File.dirname(__FILE__)
log_level                :debug
log_location             STDOUT
node_name                "xxx"
client_key               "#{current_dir}/xxx.pem"
validation_client_name   "xxx-validator"
validation_key           "#{current_dir}/xxx-validator.pem"
chef_server_url          "https://api.opscode.com/organizations/xxx"
cache_type               'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path            ["#{current_dir}/../cookbooks"]
http_proxy                "http://setyourproxyserver:80"
https_proxy               "http://setyourproxyserver:80"

require 'rest-client'
RestClient.proxy = "http://setyourproxyserver:80"




**************************************************


0 件のコメント:

コメントを投稿