packer AWS provision data with ansible in additional ebs volume

502 views
Skip to first unread message

Nik

unread,
Jun 29, 2018, 12:12:29 PM6/29/18
to Packer
Hi, 

I am trying to provision an EC2 instance in the following way.
The OS should live in an EBS root volume,  the data should stay in another EBS volume.

Here is an extract of the config:
                          "type": "amazon-ebs",
            "ami_block_device_mappings": [
                {
                    "device_name": "/dev/xvda",
                    "volume_size": 8,
                    "volume_type": "gp2"
                }
            ],
            "launch_block_device_mappings": [
                {
                    "device_name": "/dev/xvdg",
                    "volume_size": 16,
                    "volume_type": "gp2"
                }
            ]
  [...]
    "provisioners": [
        {
            "type": "shell",
            "inline": [
                                   "sudo mkfs -t ext4 /dev/xvdg",
                "sudo mkdir /data",
                "sudo mount /dev/xvdg /data"

            ]
        },
  [...]

I don't have any error in Packer.
When I try to spin up the image using only the AMI id.
Another ebs (xvdg) is correctly present but doesn't have the data I've provisioned and neither the mounted folder.

I think I should go for chroot or ebsvolume but I would like suggestions on what's the best way.

P.S,
I am using terraform to spin up the image

Thanks

Rickard von Essen

unread,
Jun 29, 2018, 2:53:24 PM6/29/18
to packe...@googlegroups.com
What's the output of "aws ec2 describe-image --image-id=..."

And the packer log? (PACKER_LOG=1 packer build template.json) 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/f075a42b-ab0b-4e38-a12c-74fa35623a58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nik

unread,
Jul 2, 2018, 5:31:17 AM7/2/18
to Packer
this is the output of the ec2 describe, the packer log is massive.

As I said the instance is provisioned correctly, it's just when spins up doesn't have the same second ebs attached but a blank one.

{
   "Images": [
       {
           "VirtualizationType": "hvm",
            "Name": "myimage-1530287803",
            "Hypervisor": "xen",
            "EnaSupport": true,
            "SriovNetSupport": "simple",
            "ImageId": "ami-64ede6f",
            "State": "available",
            "BlockDeviceMappings": [
               {
                   "DeviceName": "/dev/xvda",
                    "Ebs": {
                       "Encrypted": false,
                        "DeleteOnTermination": false,
                        "VolumeType": "gp2",
                        "VolumeSize": 8,
                        "SnapshotId": "snap-0a2e067d755b07eff"
                   }
               },
                {
                   "DeviceName": "/dev/xvdg",
                    "Ebs": {
                       "Encrypted": false,
                        "DeleteOnTermination": false,
                        "VolumeType": "gp2",
                        "VolumeSize": 16,
                        "SnapshotId": "snap-03e00acfb11a8d44a"
                   }
               }
           ],
            "Architecture": "x86_64",
            "ImageLocation": "647700225971/myimage-1530287803",
            "RootDeviceType": "ebs",
            "OwnerId": "647700225971",
            "RootDeviceName": "/dev/xvda",
            "CreationDate": "2018-06-29T15:59:22.000Z",
            "Public": false,
            "ImageType": "machine"
       }
   ]
}


Rickard von Essen

unread,
Jul 2, 2018, 5:53:35 AM7/2/18
to packe...@googlegroups.com
The packer log will give us a lot of details and reveal if everything is working as it should. 

Nik

unread,
Jul 2, 2018, 7:28:54 AM7/2/18
to Packer
That's right.

I found the issue, my Ansible script wasn't configured correctly and didn't install the files in the correct dir.

Thanks for the support.
Reply all
Reply to author
Forward
0 new messages