0

我正在尝试使用 Chef-Provisioning 来启动一些 Vagrant 虚拟机。该chef-client -z provision.rb命令运行并成功完成。我知道机器或其他东西存在,因为当我重新运行命令时它幂等地完成此运行而没有任何更改。

在knife.rb 我定义了配置文件:

profiles({
    'default' => {
    },
    'ubuntu_vagrant' => {
      :driver => 'vagrant:',
      :machine_options => {
        :vagrant_options => {
          'vm.box' => 'chef/ubuntu-14.04',
        }
      }
    },
    'ubuntu_docker' => {
      :driver => 'docker',
      :machine_options => {
        :docker_options => {
          :base_image => {
            :name => 'ubuntu',
            :tag => '14.04.2'
          }
        }
      }
    }
  })

然后我执行sudo CHEF_PROFILE=ubuntu_vagrant chef-client -z provision.rb

规定.rb:

machine 'webserver' do
  recipe 'djnginx'
end

结果:

sudo CHEF_PROFILE=ubuntu_vagrant chef-client -z provision.rb
[2015-04-18T13:13:23-08:00] INFO: Started chef-zero at http://localhost:8889 with repository at /Users/djenriquez/chef-repo
One version per cookbook

[2015-04-18T13:13:23-08:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.2.1
[2015-04-18T13:13:23-08:00] INFO: *** Chef 12.2.1 ***
[2015-04-18T13:13:23-08:00] INFO: Chef-client pid: 948
[2015-04-18T13:13:26-08:00] INFO: Run List is []
[2015-04-18T13:13:26-08:00] INFO: Run List expands to []
[2015-04-18T13:13:26-08:00] INFO: Starting Chef Run for djenriquez07
[2015-04-18T13:13:26-08:00] INFO: Running start handlers
[2015-04-18T13:13:26-08:00] INFO: Start handlers complete.
[2015-04-18T13:13:26-08:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/djenriquez07/runs
resolving cookbooks for run list: []
[2015-04-18T13:13:26-08:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2015-04-18T13:13:26-08:00] WARN: Node djenriquez07 has an empty run list.
Converging 1 resources
Recipe: @recipe_files::/Users/djenriquez/chef-repo/cookbooks/djnginx/provision.rb
* machine[webserver] action converge[2015-04-18T13:13:26-08:00] INFO: Processing machine[webserver] action converge (@recipe_files::/Users/djenriquez/chef-repo/cookbooks/djnginx/provision.rb line 1)
[2015-04-18T13:13:26-08:00] INFO: Processing vagrant_cluster[/] action create (basic_chef_client::block line 212)
[2015-04-18T13:13:26-08:00] INFO: Processing directory[/] action create (basic_chef_client::block line 15)
[2015-04-18T13:13:26-08:00] INFO: Processing file[/Vagrantfile] action create (basic_chef_client::block line 16)
[2015-04-18T13:13:26-08:00] INFO: Processing file[/webserver.vm] action create (basic_chef_client::block line 232)
[2015-04-18T13:13:26-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
[2015-04-18T13:13:31-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
[2015-04-18T13:13:31-08:00] INFO: Executing sudo cp /etc/chef/client.pem /tmp/client.pem.1379680942 on vagrant@127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed cp /etc/chef/client.pem /tmp/client.pem.1379680942 on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo chown vagrant /tmp/client.pem.1379680942 on vagrant@127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed chown vagrant /tmp/client.pem.1379680942 on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo rm /tmp/client.pem.1379680942 on vagrant@127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed rm /tmp/client.pem.1379680942 on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Processing chef_client[webserver] action create (basic_chef_client::block line 131)
[2015-04-18T13:13:32-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 142)
[2015-04-18T13:13:32-08:00] INFO: Port forwarded: local URL http://localhost:8889 is available to 127.0.0.1 as http://localhost:8889 for the duration of this SSH connection.
[2015-04-18T13:13:32-08:00] INFO: Executing sudo ls -d /etc/chef/client.rb on vagrant@127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed ls -d /etc/chef/client.rb on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo md5sum -b /etc/chef/client.rb on vagrant@127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed md5sum -b /etc/chef/client.rb on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo chef-client -v on vagrant@127.0.0.1
[2015-04-18T13:13:33-08:00] INFO: Completed chef-client -v on vagrant@127.0.0.1: exit status 0
[2015-04-18T13:13:33-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
(up to date)
[2015-04-18T13:13:33-08:00] INFO: Chef Run complete in 6.688063 seconds

Running handlers:
[2015-04-18T13:13:33-08:00] INFO: Running report handlers
Running handlers complete
[2015-04-18T13:13:33-08:00] INFO: Report handlers complete
Chef Client finished, 0/1 resources updated in 9.993406 seconds

但是我查看了virutalbox,没有看到为此实例创建的VM,也无法访问由djnginx 食谱创建的静态nginx 页面。

我的虚拟机到底在哪里?或者厨师供应实际上并没有为我创建一个流浪虚拟机?

如果我为这本食谱创建了一个 Vagrantfile 并运行vagrant up,虚拟机就会启动,并且静态 nginx 页面可供我导航到。

4

2 回答 2

0

Vagrant 机器默认存储在“.chef/vms”中。您可以通过转到此目录并运行正常的 vagrant 命令来查看它们的状态,例如:

cd .chef/vms vagrant status

您还可以使用该vagrant global-status命令查看工作站上任何 VM 的状态。这是一个有用的命令,因为它还为您提供了一个全局 ID,您可以使用它在任何 VM 上发出 vagrant 命令,而不必使用 Vagrantfile 查找目录。

于 2015-06-04T12:28:38.647 回答
0

您可能希望converge true至少在测试时设置您的机器资源。它似乎没有在创建的 VM 上运行您的配方。似乎已经创建了一个 VM 并在其上成功运行了 linux 命令,所以即使你找不到它,它也在运行。

于 2015-08-30T19:55:13.237 回答