2

我正在尝试使用 LXC 来运行测试厨房。当我使用以下 .kitchen.yml

driver:
  name: vagrant

provisioner:
  name: chef_solo
platforms:
   - name: ubuntu-12.04
     driver:
       box: precise-lxc
       provider: lxc

kitchen-converge 失败,输出如下:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=lxc ----
STDOUT: 
STDERR: The `lxc` package does not seem to be installed or is not accessible on the PATH.
---- End output of vagrant up --no-provision --provider=lxc ----
Ran vagrant up --no-provision --provider=lxc returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

我可以成功运行sudo which lxc-create,我已在 /etc/sudoers 中将我的用户更改为“NOPASSWD”。如果我vagrant up在 .kitchen/kitchen-vagrant/default-ubuntu-1204 中运行虚拟机正常启动,我可以vagrant ssh进入它并且可以看到它lxc-ls在主机系统上运行。

我试图深入研究vagrant-lxc代码并暂时注释掉 ensure_lxc_installed!调用 lib/vagrant-lxc/provider.rb。kitchen converge失败并显示以下消息:

-----> Starting Kitchen (v1.2.1)
-----> Creating <default-ubuntu-1204>...
   Bringing machine 'default' up with 'lxc' provider...
   ==> default: HandleBoxUrl middleware is deprecated. Use HandleBox instead.
   ==> default: This is a bug with the provider. Please contact the creator       
   ==> default: of the provider you use to fix this.
   ==> default: Importing base box 'precise-lxc'...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=lxc ----
STDOUT: Bringing machine 'default' up with 'lxc' provider...
==> default: HandleBoxUrl middleware is deprecated. Use HandleBox instead.
==> default: This is a bug with the provider. Please contact the creator
==> default: of the provider you use to fix this.
==> default: Importing base box 'precise-lxc'...
STDERR: There was an error executing ["sudo", "rm", "/usr/share/lxc/templates/lxc-vagrant-tmp-default-ubuntu-1204_default_1399314523513_48531"]

For more information on the failure, enable detailed logging by setting
the environment variable VAGRANT_LOG to DEBUG.
---- End output of vagrant up --no-provision --provider=lxc ----
Ran vagrant up --no-provision --provider=lxc returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

环境:

  • Linux Mint 16,内核 3.11.0-20
  • 流浪者 1.5.4
  • 流浪者LXC 0.8
  • 测试厨房 1.2.1
  • lxc 1.0.0~alpha1-0ubuntu14.1
  • 须藤 1.8.6p3-0ubuntu3.1

https://gist.github.com/AlexeyDemidov/11544964的输出kitchen diagnose --all

4

1 回答 1

2

我已经用简单的 puts 替换了插件源中对 'which lxc-create' 的 sudo_wrapper 调用,sudo which lxc-create并且得到的输出告诉我 sudo 需要 tty。在 /etc/sudoers 中注释掉“Defaults requiretty”行解决了这个问题。

于 2014-05-17T17:47:24.873 回答