简体   繁体   中英

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 ie 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)

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",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM