Merge pull request #9825 from kalefranz/ec2-inventory-tags

Allow ec2 tags to be used to address servers in ec2 dynamic inventory.
This commit is contained in:
Brian Coca 2015-02-02 12:58:58 -05:00
commit 5eafa1e7c3
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)