aws ebs: mount executed while provisioning fails

258 views
Skip to first unread message

Vaibhaw

unread,
Aug 23, 2013, 7:23:08 AM8/23/13
to packe...@googlegroups.com
 My use-case is like this:
Create a ebs backed ec2 instance which has an additional ebs volume attached that some software will be configured on during provisioning. I wish to create an AMI of this config.

So I started out by specifying no provisioners and this field in the builders object:
    [{ "type": "amazon-ebs",
         "access_key": BLAH BLAH,
         "secret_key": "bluh bluh,
         "region": "us-east-1",
         "source_ami": "ami-77fcbc1e",
         "instance_type": "t1.micro",
         "ssh_username": "ubuntu",
         "ami_name": "packer-tries-{{timestamp}}",
         "ami_block_device_mappings" : [{
             "device_name" : "/dev/sdf1",   <<<<
             "volume_size" : 20                  <<<<
              }]

If I create an ec2 instance from the resulting ami, I can run the following operation on it:
volpath="/dev/xvdf1"    # Ubuntu maps /dev/sdf1 -> /dev/xvdf1
mountpoint="/vol"
sudo mkfs.ext4 $volpath
sudo mkdir -m 000 $mountpoint
echo "$volpath $mountpoint auto noatime 0 0" | sudo tee -a /etc/fstab
sudo mount $mountpoint

So I added the above to a script and wrote a builder:
     "provisioners": [
        {
            "type": "shell",
            "scripts" : [
                "scripts/setup.sh"
            ]
          }
      ]
Now while this script executes during the provisioning phase on the temporary ec2 instance I get a device not found error:
$ packer build template.json
amazon-ebs output will be in this color.

==> amazon-ebs: Creating temporary keypair for this instance...
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Waiting for instance (i-312f8953) to become ready...
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: scripts/setup.sh
    amazon-ebs: mke2fs 1.42.5 (29-Jul-2012)
    amazon-ebs: Could not stat /dev/xvdf1 --- No such file or directory
    amazon-ebs:
    amazon-ebs: The device apparently does not exist; did you specify it correctly?
    amazon-ebs: /dev/xvdf1 /vol auto noatime 0 0
    amazon-ebs: mount: special device /dev/xvdf1 does not exist

What is wrong? Should I be using the  amazon-chroot to get this to work?

Thanks in advance for any pointers!

Tommy Groshong

unread,
Jan 11, 2016, 1:51:17 PM1/11/16
to Packer, vai...@knowledgefoundry.net
Did you ever figure this out?  I seem to be having a similar problem.
Reply all
Reply to author
Forward
0 new messages