打包程序 ssh 超时



我正在尝试在 jenkins 管道中使用 packer 构建映像。但是,打包程序 ssh 配置器不起作用,因为 ssh 永远不会可用,并且因超时而出错。对该问题的进一步调查表明,映像缺少/etc/sysconfig/network-scripts 目录中的网络接口文件 ifconfig-eth0,因此它永远不会获得 ip 并且不接受 ssh 连接。问题是,有很多这样的图像要生成,我无法在 virtualbox 的 GUI 中手动打开每个图像并纠正问题并重新打包。还有其他可能的解决方案吗?

    {
  "variables": {
    "build_base": ".",
    "isref_machine":"create-ova-caf",
    "build_name":"virtual-box-jenkins",
    "output_name":"packer-virtual-box",
    "disk_size":"40000",
    "ram":"1024",
    "disk_adapter":"ide"
  },  
  "builders":[
        {   
          "name": "{{user `build_name`}}",
          "type": "virtualbox-iso",
          "guest_os_type": "Other_64",
          "iso_url": "rhelis74_1710051533.iso",
          "iso_checksum": "",
          "iso_checksum_type": "none",
          "hard_drive_interface":"{{user `disk_adapter`}}",
          "ssh_username": "root",
          "ssh_password": "Secret1.0",
          "shutdown_command": "shutdown -P now",
          "guest_additions_mode":"disable",
          "boot_wait": "3s",
          "boot_command": [ "auto<enter>"],
          "ssh_timeout": "40m",
          "headless":
          "true",
          "vm_name": "{{user `output_name`}}",
                    "disk_size": "{{user `disk_size`}}",
          "output_directory":"{{user `build_base`}}/output-{{build_name}}",
          "format": "ovf",
          "vrdp_bind_address": "0.0.0.0",
          "vboxmanage": [
            ["modifyvm", "{{.Name}}","--nictype1","virtio"],
            ["modifyvm", "{{.Name}}","--memory","{{ user `ram`}}"]
          ],
          "skip_export":true,
          "keep_registered": true
        }   
  ],  
  "provisioners": [
    {
      "type":"shell",
      "inline": ["ls"]
    }
  ]
}

如果在预配过程中不需要 SSH 连接,可以将其关闭。请参阅有关通信器的打包程序文档,您可以在none看到在主机和来宾之间切换通信的选项。

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "communicator": "none"
    }
  ]
}

Packer Builders DOCU virtualbox-iso

相关内容

  • 没有找到相关文章