ec2 module failure for specific instance types

Hi,

I was trying to create an ec2 instance with instance type “cg1.4xlarge” or “8x.large” and image as “bitnami ubuntu13.04 32-bit”. I called my playbook inside from a python script as follows.

import sys
from subprocess import Popen, PIPE

cmd = “ansible-playbook -v -i inv test.yml”
proc = Popen([cmd], shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
stdout, stderr = proc.communicate()
if stderr:
print "Error : "
print stderr
sys.exit()
else:
print stdout

When I execute my script, I am getting the following error…

PLAY [Playbook for Amazon AWS ec2 server creation via ansible] ****************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [Launch Instances] ******************************************************
failed: [localhost] => {“failed”: true}
msg: InvalidParameterCombination: Virtualization type ‘hvm’ is required for instances of type ‘cg1.4xlarge’.

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/root/create_server.retry

localhost : ok=1 changed=0 unreachable=0 failed=1

So it seems that instead of stderr, I am getting the message in stdout. So my questions are

  1. How to create an ec2 instances of larger instance types(8x.larger or something) using ansible…??
  2. How to catch errors when executing the playbook from a python script…??

the bitnami image you selected isn’t compatible with the instance type you selected, ansible is just reporting the error from aws.

  1. pick an appropriate image for that instance type. 2. stderr and return code… subprocess.check_output([cmd], stderr=subprocess.STDOUT) will raise exc on error.