我从ubuntu shell运行以下命令,与aws平台进行对话,以自定义亚马逊ami(ami-9abea4fb
):
$ packer build -debug template.packer
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.
==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue.
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> amazon-ebs: Creating temporary keypair: packer 5dfe9f3b-9cc2-cbfa-7349-5c8ef50c64d5
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
template.packer
在哪里:
{
"builders": [
{
"type": "amazon-ebs",
"region": "us-west-2",
"source_ami": "ami-9abea4fb",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "MiddleTier-{{isotime | clean_ami_name}}",
"ami_description": "Amazon AMI customised",
"tags": {
"role": "MiddleTier"
},
"run_tags":{
"role": "buildSystem"
}
}
],
"provisioners": [
],
"post-processors":[
]
}
而且我的理解是,AWS已经为打包程序创建了一个私钥(ec2_amazon-ebs.pem
),以便以无密码的方式与EC2实例进行通信,如上述步骤所述。
但是我看不到打包程序在我的笔记本电脑中复制私钥(ec2_amazon-ebs.pem
)(作为~/.ssh/ec2_amazon-ebs.pem
)
打包程序如何与EC2通信?而不复制为笔记本电脑中的~/.ssh/ec2_amazon-ebs.pem
除非为Packer提供了带有ssh_private_key_file
的专用SSH,Packer会创建一个临时文件,该临时文件仅在Packer运行时保留在内存中。
当您使用-debug
标志运行时,此临时密钥将保存到当前工作目录中。这是为了使您能够通过手动SSH进入实例来对构建进行故障排除。