2016-07-27 129 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命令做的伎俩。

因此在生成过程中不会重新启动。