ebs

Attach and partition EBS volumes

Vivus Ignis

ignis

12,827 downloads

6,587 latest version

2.7 quality score

Version information

  • 0.3.1 (latest)
  • 0.3.0
  • 0.2.2
  • 0.2.1
  • 0.2.0
  • 0.1.5
  • 0.1.4
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Feb 19th 2016

Start using this module

Documentation

ignis/ebs — version 0.3.1 Feb 19th 2016

ebs

Table of Contents

  1. Overview
  2. Usage - Configuration options and additional functionality
  3. Limitations - OS compatibility, etc.

Overview

This module provides allows to manage EBS volumes (attach, format, mount). Volumes should be created outside of puppet, for example, using CloudFormation. The module performs a lookup searching for a volume in question by a 'name' tag's value.

All the interactions with AWS API are performed with aws commandline utilities.

Usage

Be sure to create a volume beforehand. E.g., here is a snippet for CloudFormation:

"JenkinsMasterStorageVolume": {
  "Type": "AWS::EC2::Volume",
  "Properties": {
    "Encrypted": true,
    "AvailabilityZone": "eu-west-1a",
    "Size": 100,
    "Tags": [
      {
        "Key": "name",
        "Value": "jenkins"
      }
    ]
  }
},

Or awscli:

aws ec2 create-volume --availability-zone $${AWS_DEFAULT_REGION}a \
  --size 1 --encrypted --volume-type standard \
  --query '{id:VolumeId}' \
  | grep '"id"' | awk '{print $$2}' \
  | tr -d '"' | perl -pe chomp > .volume_id
aws ec2 create-tags --resources `cat .volume_id` \
  --tags Key=name,Value=jenkins

And then in your puppet code you can create resources like this:

ebs::volume { 'jenkins':              # so we look for an EBS volume that has name:jenkins tag set
  device          => '/dev/sdz',      # it is safer to begin with sdz and go backwards alphabetically
  device_attached => '/dev/xvdad'     # hard to guess -- see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html
  format          => 'ext4',          # ext3 by default
  format_options  => '-L jenkins',    # this will be passed to mkfs.ext3 AS IS, string format
  mount_dir       => '/mnt/jenkins',  # /mnt by default
  mount_options   => 'nodev, noatime' # single string, fstab format, 'noatime' by default
}

mount_dir directory will be created if it doesn't exist (so manage it outside of this module to ensure custom owner/group/mode parameters).

Also, please be very careful with format option: if a volume was already formatted with, say, 'ext4' and you set this parameter to something else ( ext3 ) -- a volume will be reformatted and you will lose your data.

Limitations

This module was tested on CentOS 6.x and Ubuntu so far. For the AWS API authorization to work, you have to assign a proper IAM role to an ec2 instance you're running this code on. Example policy (tune Resource parameter to your liking):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1444046341000",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeVolumes",
                "ec2:AttachVolume"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}