2016-07-27 132 views
3

我對Packer和RancherOS有問題。我正嘗試使用cloud-config文件構建自定義rancherOS映像。 我正在使用MacOSX。用Packer構建RancherOS時SSH失敗

我有這個build.json文件

{ 
    "variables": { 
     "vm_name" : "" 
    }, 
    "builders": [ 
     { 
      "type": "vmware-iso", 
      "iso_url": "rancheros.iso", 
      "guest_os_type": "other", 
      "iso_checksum_type": "md5", 
      "iso_checksum": "467caa8394684ba54e8731aed8480652", 
      "output_directory": "output_rancheros", 
      "ssh_wait_timeout": "30s", 
      "shutdown_command": "sudo shutdown -h now", 
      "disk_size": 20000, 
      "ssh_username": "rancher", 
      "ssh_password": "rancher", 
      "ssh_port": 22, 
      "ssh_wait_timeout": "90m", 
      "vm_name": "{{ user `vm_name` }}", 
      "boot_wait": "10s", 
      "vmx_data": { 
       "memsize": "4096" 
      } 
     } 
    ], 
    "provisioners": [ 
     { 
      "type":"file", 
      "source": "cloud-config.yml", 
      "destination": "/tmp/cloud-config.yml" 
     }, 
     { 
      "type": "shell", 
      "inline": [ 
       "sudo ros install -d /dev/sda -f -t generic -c /tmp/cloud-config.yml" 
      ] 
     } 
    ] 
} 

沿邊我只包含我的SSH密鑰的cloud-config.yml

#cloud-config 
ssh_authorized_keys: 
    - ssh-rsa AAAA....d [email protected] 

當我啓動建設命令packer build build.json

我得到

vmware-iso: + umount /mnt/new_img 
    vmware-iso: time="2016-07-27T05:52:35Z" level=fatal msg=EOF 
    vmware-iso: Continue with reboot [y/N]: 
==> vmware-iso: Stopping virtual machine... 
==> vmware-iso: Deleting output directory... 
Build 'vmware-iso' errored: Script exited with non-zero exit status: 1 

==> Some builds didn't complete successfully and had errors: 
--> vmware-iso: Script exited with non-zero exit status: 1 

==> Builds finished but no artifacts were created. 

如果我理解正確。我的腳本正在工作,但是當VM重新啓動時,新的SSH密鑰不起作用。

我不知道如何解決這個問題。也許有人會幫助我。

問候

+0

您是否遇到過打包程序ssh超時的問題?我使用幾乎相同的json(除了使用vbox而不是vmware)並且我無法使用ssh。錯誤:「生成'virtualbox-iso'錯誤:ssh:握手失敗:ssh:無法進行身份驗證,嘗試的方法[密碼鍵盤交互無],沒有支持的方法仍然存在」 –

+0

我從來沒有嘗試過使用VirtualBox,你能創建一個在StackOverflow發佈,所以我可以幫忙嗎?我至少需要template.json文件。 – Sapher

+0

謝謝。 https://stackoverflow.com/questions/49133676/handshake-failed-ssh-unable-to-authenticate-attempted-methods-none-password –

回答

4

我找到了解決辦法

只需添加一個-no-reboot標誌上sudo ros install -d /dev/sda -f -t generic -c /tmp/cloud-config.yml命令做的伎倆。

因此在生成過程中不會重新啓動。