2013-03-04 13 views
0

을에 '해시'변환 할 수 없습니다, 내가 받고 있어요 :의 문제은 '문자열'나는 <code>capistrano</code>를 통해 어떤 이유로 배포하기 위해 노력하고있어

/Users/mysite/.rvm/gems/[email protected]/gems/json-1.4.6/lib/json/common.rb:146:in `initialize': can't convert Hash into String (TypeError) 
    from /Users/mysite/.rvm/gems/[email protected]/gems/json-1.4.6/lib/json/common.rb:146:in `new' 
    from /Users/mysite/.rvm/gems/[email protected]/gems/json-1.4.6/lib/json/common.rb:146:in `parse' 
    from /Users/mysite/.rvm/gems/[email protected]/gems/chef-capistrano-0.1.0/lib/chef/capistrano.rb:27:in `role_from_chef' 
    from ./config/deploy.rb:35:in `block in load' 

의 선을 내 config/deploy.rb은 다음과 같습니다

after 'multistage:ensure' do 
role_from_chef :db, 'app', :limit => 1, :primary => true # perform db operations on one of the app servers 
role_from_chef :web, 'app' 
role_from_chef :app 
role_from_chef :queue 
role_from_chef :cron 
end 

번째 라인은 라인 (35)

업데이트 된 코드

01,235,164이고
def role_from_chef(cap_role, *roles) 
    %w(chef_host chef_port chef_scheme chef_client_name chef_key_file).each do |value| 
     abort "Please set :#{value}" unless exists?(value.to_sym) 
    end 

    Spice.setup do |s| 
     s.host = fetch(:chef_host) 
     s.port = fetch(:chef_port) 
     s.scheme = fetch(:chef_scheme) 
     s.client_name = fetch(:chef_client_name) 
     s.key_file = fetch(:chef_key_file) 
    end 
    Spice.connect! 

    options = roles.extract_options! 
    roles = [cap_role.to_s] if roles.empty? 
    search_roles = fetch(:chef_search_roles) + roles 
    query = search_roles.map{|r| "role:#{r}"}.join(" AND ") 

    response = Spice.connection.get("/search/node?q=#{URI.encode(query)}")   
    response_object = JSON.parse(response) 
    raise response_object['error'].join(' ') if response_object.has_key?('error') 

    nodes = response_object['rows'] 
    hosts = nodes.select{|n| n['ec2']}.map{|n| n['ec2']['public_hostname']} 

    if limit = options.delete(:limit) 
     hosts = hosts.slice(0, limit) 
    end 

    hosts.each do |host| 
     node = nodes.detect { |n| n['ec2']['public_hostname'] == host } 
     puts "#{cap_role}: #{node['ec2']['instance_id']} - #{node['ec2']['public_hostname']}" 
    end 

    hosts << options 
    role cap_role, *hosts 
    end 

답변

1
role_from_chef :db, 'app', :limit => 1, :primary => true 

오류 사항에 따라

role_from_chef(:db, 'app', { :limit => 1, :primary => true }) 

동일합니다, 당신이 세 번째 매개 변수로 문자열을 받아 않습니다 role_from_chef를 작동하는지 말할 것입니다. 그러나 role_from_chef 함수를 붙이지 않으면 확신 할 수 없습니다.

은 어쨌든 그건 당신이 조사해야 내용은 다음과 같습니다 role_from_chef 내부의 세 번째 매개 변수에 따라 볼이 곳

+0

내가'role_from_chef'가하는 일의 코드를 업데이트 문자열로 사용되는 경우 – Shamoon

관련 문제