Hello everyone!
Here goes my first post in the wonderful Ansible project :)
Here's the problem that I am facing: I am trying to launch an EC2 instance (c3.2xlarge) and, in the process, I want to resize the root partition from 8GB to something bigger. Also while in the process of launching the instance, I'd like to add those two extra disks (2x80GB SSD) that come with this instance.
I do not know if this is even achievable via Ansible.
So far, I looked at these two modules:
-
http://docs.ansible.com/ec2_module.html-
http://docs.ansible.com/ec2_vol_module.htmlI played with them in different ways, with no avail. Here is what I have now to successfully launch the instance. Playbook: provision.yml
---
# http://docs.ansible.com/ec2_module.html
- name: spin up the all in one instance
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: create security group
local_action:
module: ec2_group
name: "{{ security_group }}"
description: security group for the all in one server
region: "{{ region }}"
vpc_id: "{{ vpc_id }}"
rules:
- proto: all
from_port: 0
to_port: 65535
cidr_ip: 87.193.177.242/32
rules_egress:
- proto: all
from_port: 0
to_port: 65535
cidr_ip: 0.0.0.0/0
register: ec2_group
tags: provisioning
- name: launch instance
local_action:
module: ec2
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
count: 1
region: "{{ region }}"
zone: "{{ zone }}"
instance_type: "{{ instance_type }}"
image: "{{ ami }}"
ebs_optimized: yes
state: present
group: "{{ security_group }}"
vpc_subnet_id: "{{ subnet }}"
key_name: "{{ keypair }}"
monitoring: yes
assign_public_ip: yes
wait: yes
wait_timeout: 300
volumes:
- device_name: /dev/xvda
volume_size: 20
register: ec2
# - name: adding remaining disks #(c3.2xlarge has 2x80GB SSD)
# local_action: ec2_vol instance={{ item.id }} volume_size=80 count=2
# with_items: ec2.instances
# register: ec2_vol
And for what it's worth, here are my variables host_vars/localhost:
#AWS wheezy AMI IDs => https://wiki.debian.org/Cloud/AmazonEC2Image/Wheezy
#(EU-West-1, PVM, EBS-backed, x86_64)region: eu-west-1
zone: eu-west-1a
instance_type: c3.2xlarge
ami: ami-630fcb14
#network & security
security_group: allinone
subnet: subnet-ddca27aa
vpc_id: vpc-9037d9f5
keypair: ansible-ec2You can see how I tried and shamefully failed to add those two SSDs (count parameter is not even supported by module ec2_vol) :)
Curiously enough, if I use the volumes parameter of the module ec2 as above, I get two EBS volumes showing up in the AWS console: /dev/sda and of course /dev/xvda (this one being the root device). I cannot even see /dev/sda in the EC2 instance.
FYI, this AMI launches with a 8GB root partition by default. Would be great if I could make that bigger with an Ansible module/parameter. I am very much aware on how to do this "outside" of Ansible, but it's not desired.
Second issue would be attaching those two disks that come with this instance type...
Any help/hint would be greatly appreciated.
See attached screenshot to better understand what I'm trying to achieve with Ansible.
Thank you Michael for this great tool!!
