簡體   English   中英

Packer等待SSH

[英]Packer Waiting for SSH

我是Packer的新手。 我已經非常詳細地研究了這個問題(上圖)。 我目前正在嘗試創建一個UBuntu 32位VM。 我在WIndows 10操作系統上運行Packer。 一旦安裝完成並且VM重新啟動,然后我提示使用GUI登錄我的VM,而打包器仍然運行我的主機Windows說它正在等待SSH可用。 我怎樣才能最好地使用ssh讓Packer用來連接我的虛擬機。 這是我的json.template

{
    "builders": [
      {
        "type": "virtualbox-iso",
        "vm_name": "{{ user `alias` }}",
        "vboxmanage": [          
            [ "modifyvm", "{{.Name}}", "--cpus", "1" ],
            [ "modifyvm", "{{.Name}}", "--memory", "{{user `ram`}}" ],
            [ "modifyvm", "{{.Name}}", "--clipboard", "bidirectional" ],             
            [ "modifyvm", "{{.Name}}", "--draganddrop", "bidirectional" ], 
            [ "modifyvm", "{{.Name}}", "--audio", "none" ],
            [ "modifyvm", "{{.Name}}", "--nic1", "intnet"], 
            [ "modifyvm", "{{.Name}}","--nic2", "null"],
            [ "modifyvm", "{{.Name}}","--vram", "16"],
            [ "modifyvm", "{{.Name}}","--mouse", "usbtablet"]              
          ],
        "guest_os_type": "Ubuntu",
        "iso_url": "{{ user `iso_url` }}",
        "iso_checksum": "{{ user `iso_checksum` }}",
        "iso_checksum_type": "md5",
        "disk_size": "{{ user `disk_size` }}",
        "ssh_username": "{{ user `ssh_username` }}",
        "ssh_password": "{{ user `ssh_password` }}",
        "ssh_timeout": "{{ user `ssh_timeout` }}",
        "guest_additions_mode": "attach",
        "headless": "{{ user `headless` }}", 
        "boot_wait": "3s",
        "boot_command": [
          "<enter><wait><esc><enter><wait>",
          "/install/vmlinuz<wait>",
          " {{user `preseed_path`}}",
          " debian-installer/locale=en_US console-setup/ask_detect=false<wait>",
          " console-setup/layoutcode=us<wait>",
          " keyboard-configuration/layoutcode=us<wait>",
          " passwd/user-password={{ user `ssh_password` }}<wait>",
          " passwd/user-password-again={{ user `ssh_password` }}<wait>",
          " finish-install/reboot_in_progress=note<wait>",
          " netcfg/use_autoconfig=false<wait>",
          " cdrom-detect/eject boolean=false<wait>",
          " initrd=/install/initrd.gz<wait>",
           "<enter><wait>"
        ],
        "shutdown_command": "sudo shutdown -h now"
      }
    ],
    "post-processors": [
      {
        "type": "vagrant",
        "output": "C://{{ user `box_name` }}.box"
      }
    ],
    "variables": {
      "headless": "false",
      "iso_checksum": "7",
      "iso_url": "{{file path}}",
      "disk_size": "256000",
      "alias": "packervm",
      "box_name": "ubuntu_custom",
      "ssh_timeout": "20m",
      "ssh_username": "{{username}}",
      "ssh_password": "{{password}}",
      "preseed_path":"file=/cdrom/preseed/preseed.cfg",
      "ram": "2048"
    }
  }

PS是的我在來到這里並詢問這個問題之前已經查看了模板。

實際上,我明白了。 這是將ssh_port設置為22,將ssh_address設置為我的vm地址,將ssh_skip_nat_mapping設置為true,然后將我的NIC卡從內部網絡更改為hostonly然后進行配置的組合。

您覆蓋Packers設置的網絡,因此主機將無法訪問來賓。 要解決此問題,請刪除以下兩行:

[ "modifyvm", "{{.Name}}", "--nic1", "intnet"], 
[ "modifyvm", "{{.Name}}","--nic2", "null"],

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM