简体   繁体   English

如何使用packer从vmware映像创建一个vagrant box

[英]how to create a vagrant box from vmware image with packer

I have a VMWARE image running CentOS.I want to create a vagrant box from it with packer. 我有一个运行CentOS的VMWARE映像。我想用打包器从它创建一个流浪盒。 I am new to Vagrant and can anyone suggest the steps? 我是Vagrant的新手,有人可以建议这些步骤吗?

Using Packer to apply additional provisioning steps to an existing VM is supported by Packer via the vmware-vmx builder Packer通过vmware-vmx构建器支持使用Packer将其他配置步骤应用于现有VM

This VMware Packer builder is able to create VMware virtual machines from an existing VMware virtual machine (a VMX file). 此VMware Packer构建器能够从现有VMware虚拟机(VMX文件)创建VMware虚拟机。 It currently supports building virtual machines on hosts running VMware Fusion Professional for OS X, VMware Workstation for Linux and Windows, and VMware Player on Linux. 它目前支持在运行适用于OS X的VMware Fusion Professional,适用于Linux和Windows的VMware Workstation以及Linux上的VMware Player的主机上构建虚拟机。

In your situation where you have an existing CentOS VMX and want to turn it into a Vagrant box you would create packer.json configuration file like so: 在您拥有现有CentOS VMX并希望将其变为Vagrant框的情况下,您将创建packer.json配置文件,如下所示:

{
  "builders": [{
    "type": "vmware-vmx",
    "source_path": "/path/to/a/vm.vmx",
    "ssh_username": "root",
    "ssh_password": "root",
    "ssh_wait_timeout": "30s",
    "shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
  }],
  "provisioners": [{
    "type": "shell",
    "inline": ["echo 'my additional provisioning steps'"]
  }],
  "post-processors": [{
    "type": "vagrant",
    "keep_input_artifact": true,
    "output": "mycentos.box"
  }]
}

Packer would clone the source VMX, boot the box, apply any provisioning steps you had, shut down the box, and then output a new Vagrant ".box" file. Packer将克隆源VMX,启动该框,应用您拥有的任何配置步骤,关闭该框,然后输出新的Vagrant“.box”文件。

It sounds like you won't be able to. 听起来你无法做到。 Packer assumes a base box (for vagrant) and ends at a new box. Packer假定一个基础盒(用于流浪者)并在一个新盒子结束。 You can't go from a running VM to a box via Packer. 您无法通过Packer从正在运行的VM转到盒子。

If you started the CentOS VM using vagrant, you can do vagrant export If you have a running VM you made manually, your best bet is to start over using a Vagrant box. 如果您使用vagrant启动CentOS VM,您可以进行vagrant export如果您手动创建了正在运行的VM,最好的办法是重新使用Vagrant框。 If you want to continue with this route: http://docs.vagrantup.com/v2/vmware/boxes.html 如果您想继续这条路线: http//docs.vagrantup.com/v2/vmware/boxes.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM