使用Chef-Provisioning产生数字海洋机器

时间:2016-06-17 11:23:19

标签: chef

我正在尝试通过Chef Provisioning生成Digital Ocean的节点。我按照链接: https://github.com/chef/chef-provisioning-fog

但它不起作用并给出如下错误:

 ================================================================================
    Error executing action `converge` on resource 'machine[aaaa]'
    ================================================================================

    ArgumentError
    -------------
    wrong number of arguments (1 for 0)

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/spawn-nodes/recipes/default.rb

     28: machine "aaaa"


    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/spawn-nodes/recipes/default.rb:28:in `from_file'

    machine("aaaa") do
      action [:converge]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      chef_server {:chef_server_url=>"https://mayank-chef-1/organizations/digitalocean", :options=>{:client_name=>"admin", :signing_key_filename=>"/root/chef-repo/.chef/admin.pem", :api_version=>"0"}}
      driver "fog:DigitalOcean"
      machine_options {:bootstrap_options=>{:image_distribution=>"Ubuntu", :image_name=>"14.04.4 x64", :flavor_name=>"2GB", :region_name=>"New York 3", :key_name=>"MayankPorwalSSHkey"}}
      declared_type :machine
      cookbook_name "spawn-nodes"
      recipe_name "default"
    end

    Platform:
    ---------
    x86_64-linux

[2016-06-17T07:12:21-04:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2016-06-17T07:12:21-04:00] ERROR: Running exception handlers
Running handlers complete
[2016-06-17T07:12:21-04:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 07 seconds
[2016-06-17T07:12:21-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-06-17T07:12:21-04:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-06-17T07:12:21-04:00] ERROR: machine[aaaa] (spawn-nodes::default line 28) had an error: ArgumentError: wrong number of arguments (1 for 0)
[2016-06-17T07:12:21-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

这是我的spawn-nodes recipe的default.rb文件的代码:

#
# Cookbook Name:: spawn-nodes
# Recipe:: default
#
# Copyright 2016, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
require "chef/provisioning"
require "chef/provisioning/fog_driver/recipe_dsl"

chef_gem "chef-provisioning-fog" do
  compile_time false
  action :install
end

with_driver "fog:DigitalOcean"

add_machine_options :bootstrap_options => {
  :image_distribution => "Ubuntu",
  :image_name => "14.04.4 x64",
  :flavor_name => "2GB",
  :region_name => "New York 3",
  :key_name => "MayankPorwalSSHkey"
}

machine "aaaa"

有人可以告诉我我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

今天我遇到了一些问题。它看起来像一个bug,它根本不起作用。要了解检查/var/chef/cache/chef-stacktrace.out所需的核心问题。对我来说,它说(我通过Brew在MacBook上安装了ChefDK,所以我希望你的路径可以不同):

ArgumentError: machine[mysimpleserver] (@recipe_files::/opt/snapscreen/autoscaler/test.rb line 13) had an error: ArgumentError: wrong number of arguments (1 for 0)
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/fog-1.38.0/lib/fog/digitalocean/requests/compute_v2/list_ssh_keys.rb:5:in `list_ssh_keys'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/fog-1.38.0/lib/fog/digitalocean/models/compute_v2/ssh_keys.rb:17:in `all'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/fog-core-1.40.0/lib/fog/core/collection.rb:113:in `lazy_load'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/fog-core-1.40.0/lib/fog/core/collection.rb:28:in `select'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-fog-0.19.0/lib/chef/provisioning/fog_driver/providers/digitalocean.rb:75:in `bootstrap_options_for'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-fog-0.19.0/lib/chef/provisioning/fog_driver/driver.rb:319:in `block in create_servers'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-fog-0.19.0/lib/chef/provisioning/fog_driver/driver.rb:297:in `each'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-fog-0.19.0/lib/chef/provisioning/fog_driver/driver.rb:297:in `create_servers'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-fog-0.19.0/lib/chef/provisioning/fog_driver/driver.rb:191:in `allocate_machine'

所以看起来在ssh_keys.rb中它们传递了不期望的参数。如果您打开此文件,您将找到此方法的方法:

    def all(filters={})
      data = service.list_ssh_keys(filters)
      links = data.body["links"]
      get_paged_links(links)
      keys = data.body["ssh_keys"]
      load(keys)
    end

虽然service.list_ssh_keys不期望任何参数。如果您要对此文件进行更改并删除过滤器参数,那么它将起作用。

我认为这是一个错误。有空的时候会报告。