Allow ec2 tags to be used to address servers in ec2 dynamic inventory.

This commit is contained in:
Kale Franz 2014-12-15 22:31:29 -08:00
parent bfe08560ec
commit 28e69b9017
2 changed files with 11 additions and 4 deletions

View file

@ -385,9 +385,13 @@ class Ec2Inventory(object):
# Select the best destination address
if instance.subnet_id:
dest = getattr(instance, self.vpc_destination_variable)
dest = getattr(instance, self.vpc_destination_variable, None)
if dest is None:
dest = getattr(instance, 'tags').get(self.vpc_destination_variable, None)
else:
dest = getattr(instance, self.destination_variable)
dest = getattr(instance, self.destination_variable, None)
if dest is None:
dest = getattr(instance, 'tags').get(self.destination_variable, None)
if not dest:
# Skip instances we cannot address (e.g. private VPC subnet)