2015-07-28 99 views
0

我很高興地使用Vagrant和Chef Solo,但我讀到使用Chef Zero將導致更輕鬆地過渡到完整的廚師服務器(這可能會在項目近期發生) 。當我開始使用流浪漢和廚師零號時,我會在主廚運行過程中遇到錯誤,如下所述。
流浪:1.7.4
廚師(客戶機) - 12.4.1
當我做了$ vagrant up db,這是從廚師流浪和廚師零 - 失蹤的角色

==> db: [2015-07-28T09:14:13+00:00] INFO: Chef-client pid: 2525 
==> db: [2015-07-28T09:14:14+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/db-machine 
==> db: [2015-07-28T09:14:14+00:00] INFO: Setting the run_list to ["role[mysql]"] from CLI options 
==> db: [2015-07-28T09:14:14+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/roles/mysql 
==> db: [2015-07-28T09:14:14+00:00] ERROR: Role mysql (included by 'top  level') is in the runlist but does not exist. Skipping expand. 
==> db: Error expanding the run_list: 
==> db: 
==> db: 
==> db: Missing Role(s) in Run List: 
==> db: ---------------------------- 
==> db: * mysql included by 'top level' 
==> db: 
==> db: Original Run List 
==> db: ----------------- 
==> db: * role[mysql] 

輸出這是我Vagrantfile的相關位

machine.vm.provision "chef_zero" do |chef| 
    chef.node_name = @hostname 
    chef.cookbooks_path = "#{@chef_repo}/cookbooks" 
    chef.roles_path = "#{@chef_repo}/roles" 
    chef.environments_path = "#{@chef_repo}/environments" 
    chef.environment = @environment 
    roles.each do |role| 
     chef.add_role role 
    end 
    chef.json = { 
     "guest_folder_path" => guest_path, 
     "ubuntu_user" => @ubuntu_user 
    } 
end 

當我登錄到虛擬機(db)和去/tmp/chef-vagrant

$ cd /tmp/vagrant-chef/ 
    [email protected]:/tmp/vagrant-chef$ ls 
    2107f3d10c0db9887cdf980054c11e35/ client.rb       dna.json 
    8a1f8968cff1cd79d46fc9ca5bd46931/ df5881620e1c72537e51bddcbc6ceb3a/ 
    [email protected]:/tmp/vagrant-chef$ cat client.rb 
    node_name "db-machine" 
    file_cache_path "/var/chef/cache" 
    file_backup_path "/var/chef/backup" 
    cookbook_path ["/tmp/vagrant-chef/df5881620e1c72537e51bddcbc6ceb3a/cookbooks"] 
    role_path "/tmp/vagrant-chef/2107f3d10c0db9887cdf980054c11e35/roles" 
    log_level :info 
    verbose_logging false 
    enable_reporting false 
    encrypted_data_bag_secret nil 
    environment_path "/tmp/vagrant-chef/8a1f8968cff1cd79d46fc9ca5bd46931/environments" 
    environment "develop" 
    chef_zero.enabled true 
    local_mode true 
    add_formatter "null" 

這是內容/角色

[email protected]:/tmp/vagrant-chef/2107f3d10c0db9887cdf980054c11e35/roles$ ls 
mysql.rb 
[email protected]:/tmp/vagrant-chef/2107f3d10c0db9887cdf980054c11e35/roles$ cat mysql.rb 
name "mysql" 
description "Role for a machine with a mysql db on it" 
run_list "recipe[db]" 
env_run_lists "_default"=>[], 
"production" => ["recipe[git_deploy]", "recipe[db::aws]", "recipe[db]"], 
"staging" =>["recipe[git_deploy]", "recipe[db::aws]", "recipe[db]"], 
"develop" => ["recipe[db]"] 


default_attributes "mysql_bind_address" =>"0.0.0.0", 
    "mysql_db_name"=> "some_db_name", 
    "mysql_password"=> "root", 
    "mysql_datadir" => "/var/lib/mysql", 
    "db_name" => "some_db_name", 
    "db_init_runlist" => [ 
       "some_file.sql", 
       "some_other_file.sql" 
    ] 

回答

3

顯然RB角色定義不是廚師零隻有那些JSON支持。

Chef Zero Bug reported

,一個是封閉的,而是指其他那仍然是開放的。

我有同樣的問題,所以我的解決方案是使用這個gist來將我的角色轉換爲JSON,並以這種方式與流浪者一起使用它們。

+0

確實是正確的,'chef-zero'只支持json格式的角色,請參閱[關於角色json格式](https://docs.chef.io/roles.html#json)以獲取更多信息 – MrRoth