简体   繁体   English

Packer + Vagrant-从ISO创建AMI

[英]Packer + Vagrant - create AMI from ISO

Is it possible to create an AMI from an ISO? 是否可以从ISO创建AMI?

I am implementing a build system which uses the base iso, modifies it, installs stuff and then outputs it in .ovf and AMI. 我正在实现一个使用基本iso的构建系统,对其进行修改,安装内容,然后将其输出到.ovf和AMI中。

.ovf works. .ovf作品。 But for AMI, all I could figure out is it needs pre existing AMI. 但是对于AMI,我能弄清楚的是它需要预先存在的AMI。 Is this correct? 它是否正确?

Is there any way to use an iso and generate an AMI? 有什么方法可以使用iso并生成AMI?

Thanks. 谢谢。

When you say from ISO that tells me you're looking to create a trusted base VM. 当您从ISO告诉我,您正在寻找一个受信任的基础VM。 You want to install from scratch locally first and import that to ec2 as a trusted private AMI. 您想首先从本地安装,然后将其作为受信任的专用AMI导入ec2。 If you don't mind using veewee there's an awesome post using veewee instead of packer here: veewee It's all setup for CentOS. 如果您不介意使用veewee,这里有一篇很棒的文章使用veewee而不是packer: veewee这都是CentOS的设置。 All you need to do is clone it and tweak it for your use case. 您需要做的就是克隆它,并针对您的用例进行调整。

But since you're looking for packer like I was then what you need is the virtualbox-iso builder in packer and some aws-cli commands to upload and create an AMI out of the OVA. 但是,由于您正在寻找像我一样的打包程序,因此您需要的是打包程序中的virtualbox-iso构建器和一些aws-cli命令,用于从OVA中上载和创建AMI。 Packer doesn't have a post-processor for this unfortunately. 很遗憾,Packer没有后处理程序。 Then you can use vagrant to reference the new AMI for ec2 based development and use the vagrant-aws plugin to create new ami's out of your trusted base ami. 然后,您可以使用vagrant引用新的AMI以进行基于ec2的开发,并使用vagrant-aws插件从您信任的基本ami中创建新的ami。

Here are the steps to follow: 以下是要遵循的步骤:

1.) Create an S3 bucket for image imports. 1.)创建用于图像导入的S3存储桶。

2.) Set up your AWS account. 2.)设置您的AWS账户。 Create 'vmimport' IAM role and policy as well as X509 key and cert pair in case you don't have it. 创建“ vmimport” IAM角色和策略以及X509密钥和证书对(如果没有)。 You'll need this to register a private AMI. 您将需要此来注册专用AMI。 You will also reference the bucket's name for the policy. 您还将参考策略的存储桶名称。

3.) Build a VM with VirtualBox using packer's virtualbox-iso builder and have it output an image in ova format. 3.)使用打包程序的virtualbox-iso构建器使用VirtualBox构建VM,并以ova格式输出映像。

4.) use aws-cli with your aws account to upload the OVA to the bucket you created. 4.)在您的aws帐户中使用aws-cli将OVA上传到您创建的存储桶。 aws s3 cp command. aws s3 cp命令。

5.) Register the OVA as an ami. 5.)将OVA注册为ami。 You will use the aws ec2 import-image command for this. 您将为此使用aws ec2 import-image命令。 (This part can take a long time 30 min - 1 hour). (这部分可能需要30分钟-1小时的时间)。

You can track progress with: aws ec2 describe-import-image-tasks The AMI will appear in your Private AMI list when it's done. 您可以使用以下方法跟踪进度: aws ec2 describe-import-image-tasks ,AMI将出现在“专用AMI”列表中。

Vagrant includes a useful little plugin called vagrant-ami which lets you create EC2 custom AMIs: Vagrant包含一个有用的小插件,名为vagrant-ami,可用于创建EC2自定义AMI:

$ vagrant create-ami new_image --name my-ami --desc "My AMI"

Then you can replace the AMI ID in your Vagrantfile with your custom one. 然后,您可以用自定义的ID替换Vagrantfile中的AMI ID。

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

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