流浪汉和厨师零-缺失的角色



我很高兴使用Vagrant和Chef Solo,但我读到使用Chef Zero将更容易过渡到完整的Chef Server(这可能会在项目的不久的将来发生)。当我开始使用vagrant + Chef -zero时,我在Chef运行期间得到错误,如下所述。
流浪汉:1.7.4
Chef(在客户机上)- 12.4.1
当我做一个$ vagrant up db时,这是Chef

的输出
==> 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/
    vagrant@db-machine:/tmp/vagrant-chef$ ls
    2107f3d10c0db9887cdf980054c11e35/  client.rb                          dna.json
    8a1f8968cff1cd79d46fc9ca5bd46931/  df5881620e1c72537e51bddcbc6ceb3a/
    vagrant@db-machine:/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"

这是/roles的内容

vagrant@db-machine:/tmp/vagrant-chef/2107f3d10c0db9887cdf980054c11e35/roles$ ls
mysql.rb
vagrant@db-machine:/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"
    ]

显然chef zero中不支持rb角色定义,只支持JSON角色定义。

Chef Zero Bug报告

指的是另一个仍然开着的。

我也有同样的问题,所以我的解决方案是使用这个要点将我的角色转换为JSON,并以这种方式与vagrant一起使用。

最新更新