ankshah
ankshah

Reputation: 435

Instance type from ansible ec2_remote_facts

I am using ec2_remote_facts module in ansible to retrieve all AWS EC2 instances procured by different users. But the instance type i.e c3.large or m1.small is not available in the information returned. How can I access the instance type? (It is available in the EC2-console)

Upvotes: 1

Views: 319

Answers (1)

helloV
helloV

Reputation: 52393

Instance type is not returned by ec2_remote_facts.

One way to get this is to monkey patch your ansible. Go to your ansible install directory. If you don't know where it is, try:

python -c 'import ansible; print locals()'

Edit modules/extras/cloud/amazon/ec2_remote_facts.py file and add:

'instance_type': instance.instance_type,

to instance_info directory in method get_instance_info(). Now you can see instance type is returned.

        "image_id": "ami-46b122622",
        "instance_type": "t2.small",
        "launch_time": "2016-11-14T21:14:44.000Z",

Upvotes: 2

Related Questions