打包程序:ssh 通信器忽略 "ssh_port"
packer: ssh communicator ignores "ssh_port"
我正在构建类型为 "virtualbox-iso" 和 OpenSUSE 42.3 作为来宾的 VirtualBox VM OS.I 我正在指定 ssh 通信器在构建过程中应该使用的主机和端口,但它看起来像 packer正在忽略端口规范。
我正在覆盖 "builders" 部分中主机和端口的默认设置。这是我的 json 文件的摘录:
"builders": [
{
"type": "virtualbox-iso",
"communicator": "ssh",
"ssh_host": "192.168.1.5",
"ssh_port": "22",
"ssh_username": "some_user",
"ssh_password": "some_password",
"ssh_timeout": "20m",
"ssh_handshake_attempts": "1000",
Packer 无法连接到 VM,因为 packer 忽略了我提供的端口 "ssh_port"。
这是调试输出(启用 PACKER_LOG=1):
2019/06/10 15:10:10 packer: 2019/06/10 15:10:10 [INFO] Waiting 1s
2019/06/10 15:10:11 ui: ==> opensuse-master-box: Using ssh communicator to connect: 192.168.1.5
2019/06/10 15:10:11 packer: 2019/06/10 15:10:11 [INFO] Waiting for SSH, up to timeout: 20m0s
2019/06/10 15:10:11 ui: ==> opensuse-master-box: Waiting for SSH to become available...
2019/06/10 15:10:26 packer: 2019/06/10 15:10:26 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: i/o timeout
2019/06/10 15:10:31 packer: 2019/06/10 15:10:31 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
2019/06/10 15:10:36 packer: 2019/06/10 15:10:36 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
2019/06/10 15:10:41 packer: 2019/06/10 15:10:41 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
这是预期的行为还是我做错了什么?
这是因为 VirtualBox NAT 网络的工作方式。您无法从主机直接访问来宾 VM。 Packer 通过设置端口转发规则来解决这个问题。 ssh_host_port_min and ssh_host_port_max is forwarded to the guest VMs ssh_port.
之间的随机端口
如果您想将 ssh_skip_nat_mapping 设置为 true
,但您必须确保您的网络设置可以让 Packer 访问来宾。
这是因为你做的是“22”而不是 22。配置正在寻找一个 int,而不是一个字符串。
我正在构建类型为 "virtualbox-iso" 和 OpenSUSE 42.3 作为来宾的 VirtualBox VM OS.I 我正在指定 ssh 通信器在构建过程中应该使用的主机和端口,但它看起来像 packer正在忽略端口规范。
我正在覆盖 "builders" 部分中主机和端口的默认设置。这是我的 json 文件的摘录:
"builders": [
{
"type": "virtualbox-iso",
"communicator": "ssh",
"ssh_host": "192.168.1.5",
"ssh_port": "22",
"ssh_username": "some_user",
"ssh_password": "some_password",
"ssh_timeout": "20m",
"ssh_handshake_attempts": "1000",
Packer 无法连接到 VM,因为 packer 忽略了我提供的端口 "ssh_port"。 这是调试输出(启用 PACKER_LOG=1):
2019/06/10 15:10:10 packer: 2019/06/10 15:10:10 [INFO] Waiting 1s
2019/06/10 15:10:11 ui: ==> opensuse-master-box: Using ssh communicator to connect: 192.168.1.5
2019/06/10 15:10:11 packer: 2019/06/10 15:10:11 [INFO] Waiting for SSH, up to timeout: 20m0s
2019/06/10 15:10:11 ui: ==> opensuse-master-box: Waiting for SSH to become available...
2019/06/10 15:10:26 packer: 2019/06/10 15:10:26 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: i/o timeout
2019/06/10 15:10:31 packer: 2019/06/10 15:10:31 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
2019/06/10 15:10:36 packer: 2019/06/10 15:10:36 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
2019/06/10 15:10:41 packer: 2019/06/10 15:10:41 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 192.168.1.5:4240: connect: connection refused
这是预期的行为还是我做错了什么?
这是因为 VirtualBox NAT 网络的工作方式。您无法从主机直接访问来宾 VM。 Packer 通过设置端口转发规则来解决这个问题。 ssh_host_port_min and ssh_host_port_max is forwarded to the guest VMs ssh_port.
之间的随机端口如果您想将 ssh_skip_nat_mapping 设置为 true
,但您必须确保您的网络设置可以让 Packer 访问来宾。
这是因为你做的是“22”而不是 22。配置正在寻找一个 int,而不是一个字符串。