![Test Kitchen 未检测到 winrm 并使用 SSH 为 Windows 客户机提供服务](https://linux22.com/image/688737/Test%20Kitchen%20%E6%9C%AA%E6%A3%80%E6%B5%8B%E5%88%B0%20winrm%20%E5%B9%B6%E4%BD%BF%E7%94%A8%20SSH%20%E4%B8%BA%20Windows%20%E5%AE%A2%E6%88%B7%E6%9C%BA%E6%8F%90%E4%BE%9B%E6%9C%8D%E5%8A%A1.png)
我是第一次测试带窗户的厨房
我正在使用带有 Vagrant (virtualbox) 的 Test Kitchen 在 Windows 机器上测试厨师食谱
我有win-2012-r2
一个可以与 Vagrant 配合使用的盒子(winrm 和 rdp 都可以使用)
但是,当使用与厨房相同的方法时,它会尝试连接 SSH,而不是winrm
这是我的.kitchen.yml
文件
---
driver:
name: vagrant
provisioner:
name: chef_zero
verifier:
name: inspec
transport:
name: winrm
elevated: true
platforms:
- name: win-2012-r2
driver:
box: win-2012-r2
communicator: 'winrm'
winrm_username: 'admin'
winrm_password: 'adminadmin'
suites:
- name: default
run_list:
- recipe[ttest::default]
运行时kitchen test
,输出为
-----> Starting Kitchen (v1.11.1)
-----> Cleaning up any prior instances of <default-win-2012-r2>
-----> Destroying <default-win-2012-r2>...
Finished destroying <default-win-2012-r2> (0m0.00s).
-----> Testing <default-win-2012-r2>
-----> Creating <default-win-2012-r2>...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'win-2012-r2'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: kitchen-ttest-default-win-2012-r2_default_1472129655910_94157
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
......................
STDERR: Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
不确定我遗漏了哪里。
Test Kitchen version 1.11.1
Vagrant 1.8.5
VirtualBox 5.1
谢谢大家
答案1
尝试将其设置port
为 5985(或您需要的任何端口。
例如:
platforms: - name: windows2016 transport: name: winrm elevated: true port: 5985
如果这不起作用,请尝试kitchen converge -l debug
获取有关机器超时原因的更多信息。
答案2
我遇到了类似的问题,就我而言,为了解决这个问题,我需要在 kitchen.yml 文件中将通信器属性指定为“winrm”:
driver:
name: vagrant
boot_timeout: 1200
gui: true
communicator: winrm
另外,我注意到您的凭据与我的不同。我在“platform”/“driver_config”下指定“用户名”和“密码”,而不是“winrm_username”和“winrm_password”。此外,就我而言,我的端口不是典型的 5985,因为它是一个自定义的 Virtual Box,而就我而言,55985(HOST)被映射到 5985(GUEST),但您需要使用 Zwadderich 提到的正确端口:
transport:
name: winrm
elevated: true
username: Tester
password: [PASSWORD]
port: 5985
因为我的盒子是自定义的 Windows 盒子,所以名称与 vagrant 所知的盒子相匹配
platforms:
- name: VAGRANT-CUSTOM-BOX-NAME
driver_config:
username: Tester
password: [PASSWORD]
vm_hostname: false
driver:
port: 55985
customize:
memory: 4048
“driver_config”部分似乎会影响生成的 vagrant 文件,该文件用于使用 vagrant 调出该框。希望这对您有所帮助!