我正在尝试为我的ami附加更多的卷,这是我的构建器部分,
Contains(container, a);
请帮助。
答案 0 :(得分:1)
这将为您和其他10Gb磁盘提供资源:
{
"builders" : [
{
"type" : "amazon-ebs",
"instance_type" : "t2.micro",
"ssh_username" : "ubuntu",
"ami_name" : "packer-ES-{{timestamp}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"launch_block_device_mappings" : [
{
"device_name" : "/dev/sdb",
"delete_on_termination" : true,
"volume_size" : 10,
"volume_type" : "gp2"
}
],
"ami_block_device_mappings" : [
{
"device_name" : "/dev/sdb",
"delete_on_termination" : true,
"volume_type" : "gp2"
}
]
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"lsblk",
"df -h"
]
}
]
}
运行此命令,您将看到:
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: /var/folders/_t/lsk64yf93xs3slvvtc6b_6mr0000gn/T/packer-shell591343041
amazon-ebs: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
amazon-ebs: xvda 202:0 0 8G 0 disk
amazon-ebs: └─xvda1 202:1 0 8G 0 part /
amazon-ebs: xvdb 202:16 0 10G 0 disk
amazon-ebs: Filesystem Size Used Avail Use% Mounted on
amazon-ebs: udev 488M 0 488M 0% /dev
amazon-ebs: tmpfs 100M 3.0M 97M 3% /run
amazon-ebs: /dev/xvda1 7.7G 956M 6.8G 13% /
amazon-ebs: tmpfs 496M 0 496M 0% /dev/shm
amazon-ebs: tmpfs 5.0M 0 5.0M 0% /run/lock
amazon-ebs: tmpfs 496M 0 496M 0% /sys/fs/cgroup
amazon-ebs: tmpfs 100M 0 100M 0% /run/user/1000
==> amazon-ebs: Stopping the source instance...
amazon-ebs: Stopping instance, attempt 1
验证结果:
env AWS_PROFILE=packer-demo AWS_DEFAULT_REGION=eu-west-1 aws ec2 describe-images --image-ids ami-0a53
cb1f4541b55d4
{
"Images": [
{
"Architecture": "x86_64",
"CreationDate": "2018-07-19T09:52:53.000Z",
"ImageId": "ami-0a53cb1f4541b55d4",
"ImageLocation": "965990659467/packer-ES-1531993870",
"ImageType": "machine",
"Public": false,
"OwnerId": "965990659467",
"State": "available",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": true,
"SnapshotId": "snap-0e622d809cf0e148a",
"VolumeSize": 8,
"VolumeType": "gp2"
}
},
{
"DeviceName": "/dev/sdb",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": false,
"SnapshotId": "snap-0c65cdcdb579f21b4",
"VolumeSize": 10,
"VolumeType": "standard"
}
},
{
"DeviceName": "/dev/sdc",
"VirtualName": "ephemeral1"
}
],
"EnaSupport": true,
"Hypervisor": "xen",
"Name": "packer-ES-1531993870",
"RootDeviceName": "/dev/sda1",
"RootDeviceType": "ebs",
"SriovNetSupport": "simple",
"VirtualizationType": "hvm"
}
]
}
如果您不需要在sdb上设置任何内容,则可以完全删除launch_device_mappings
部分,然后将volume_size
移动到ami_device_mappings
中。