stopped instances don't show in the ec2 inventory

ec2.ini says:

By default, only EC2 instances in the ‘running’ state are returned. Set

‘all_instances’ to True to return all instances regardless of state.

all_instances = True

but ec2.py still seems to ignore stopped hosts because it has this:

Select the best destination address

if instance.subnet_id:
dest = getattr(instance, self.vpc_destination_variable)
else:
dest = getattr(instance, self.destination_variable)

if not dest:

Skip instances we cannot address (e.g. private VPC subnet)

return

What’s the proper solution here?

The EC2 inventory script is an example designed to be customized to your own needs if the stock version does not fit your needs, but for most people it does. I’m also not sure that’s the part that deals with stopped hosts :slight_smile:

Instances that are disabled intentionally don’t show up, because you can’t talk to them – which is what most people want.

I assume you may be wanting something different - but I’m not sure why. Sure, they could be put in another group or be given a disabled variable, but that’s not appropriate for most people.

Perhaps a good question for ansible-devel list.

The EC2 inventory script is an example designed to be customized to your own needs if the stock version does not fit your needs, but for most people it does. I’m also not sure that’s the part that deals with stopped hosts :slight_smile:

Instances that are disabled intentionally don’t show up, because you can’t talk to them – which is what most people want.

Then the documentation in ec2.ini is wrong, I guess.

I assume you may be wanting something different - but I’m not sure why.

I want to start them for example, but also I want to know what AMI they use, before I start them.

Hey Damian,

Then the documentation in ec2.ini is wrong, I guess.

The documentation is right, I was going to point you to where to customize the script (which is here), but I found out that they modified the script to include all instances if that’s what you want. If you want to verify anything related to the ami info, that place on the script is probably where you want to do it since as well since you have an object with all instance info.

Hey, I still face the same problem…

Even if I make the adjustments on the ec2.ini file as:

https://gist.github.com/zerOnepal/83b66faf52f4d2b7b1a7/revisions

and run

./ec2.py --list

:( my stopped servers are not getting listed... I tried cleaning the ansible cache... still no luck

I am trying do multiple stuffs like: to start the stopped staging servers from list generated with ec2.py

Any wise advice,

Thanks