Cloud-init provides the disk_setup, fs_setup and mounts modules to partition, format and mount a volume to a virtual machine, however these options remain undocumented at both http://cloudinit.readthedocs.org and AWS.
Does there exist a functional example of cloud-init configuration that will partition, format and mount a single EBS volume at AWS to an instance provisioned as follows:
"Volume" : {
"Type" : "AWS::EC2::Volume",
"Properties" : {
"Size" : "100",
"VolumeType" : "gp2",
"AvailabilityZone" : { "Fn::GetAtt" : [ "ServerInstance", "AvailabilityZone" ] }
},
"DeletionPolicy" : "Delete"
},
"MountVolume" : {
"Type" : "AWS::EC2::VolumeAttachment",
"Properties" : {
"InstanceId" : { "Ref" : "ServerInstance" },
"VolumeId" : { "Ref" : "Volume" },
"Device" : "/dev/sdh"
}
},
The closest I have so far is the following (with syntax issues corrected):
disk_setup:
/dev/xvdh:
layout: true
overwrite: false
table_type: 'mbr'
fs_setup:
- label: data
device: /dev/xvdh0
filesystem: ext4
mounts:
- [ xvdh0, /opt/data ]
According to the cloud-init-output.log the attempt to partition fails as follows:
2015-12-08 15:23:11,534 - util.py[WARNING]: Failed partitioning operation
'list' object has no attribute 'splitlines'
(For reasons undocumented an attempt to create a volume called /dev/sdh results in a partition appearing called /dev/xvdh, thus the mismatch in naming)