summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorHerby Gillot <herby.gillot@axial.net>2013-09-23 21:40:18 -0400
committerHerby Gillot <herby.gillot@axial.net>2013-09-23 21:40:18 -0400
commit6ddebb3fadda0b68c3e357998aff5ba5415a27b0 (patch)
tree1f3a00ffb1ac0641edeb644f6e45e2c39b29913e /plugins
parent91785ba045831a6aa39733f614ba59d5f37dbb26 (diff)
downloadansible-6ddebb3fadda0b68c3e357998aff5ba5415a27b0.tar.gz
ec2 inventory route53 tagging:
* make filtering more comprehensive * add checks against missing route53 zone exclusion option
Diffstat (limited to 'plugins')
-rw-r--r--plugins/inventory/ec2.ini8
-rwxr-xr-xplugins/inventory/ec2.py10
2 files changed, 10 insertions, 8 deletions
diff --git a/plugins/inventory/ec2.ini b/plugins/inventory/ec2.ini
index 170505fe33..01a4982d62 100644
--- a/plugins/inventory/ec2.ini
+++ b/plugins/inventory/ec2.ini
@@ -36,11 +36,11 @@ vpc_destination_variable = ip_address
# To tag instances on EC2 with the resource records that point to them from
# Route53, uncomment and set 'route53' to True.
-#
-# Optionally, you can specify the list of zones to exclude looking up in
-# 'route53_excluded_zones' as a comma-seperated list.
route53 = False
-route53_excluded_zones =
+
+# Additionally, you can specify the list of zones to exclude looking up in
+# 'route53_excluded_zones' as a comma-seperated list.
+# route53_excluded_zones = samplezone1.com, samplezone2.com
# API calls to EC2 are slow. For this reason, we cache the results of an API
# call. Set this to the path you want cache files to be written to. Two files
diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py
index 41b8729406..c533a77b38 100755
--- a/plugins/inventory/ec2.py
+++ b/plugins/inventory/ec2.py
@@ -207,7 +207,10 @@ class Ec2Inventory(object):
# Route53
self.route53_enabled = config.getboolean('ec2', 'route53')
- self.route53_excluded_zones = config.get('ec2', 'route53_excluded_zones', '').split(',')
+ self.route53_excluded_zones = []
+ if config.has_option('ec2', 'route53_excluded_zones'):
+ self.route53_excluded_zones.extend(
+ config.get('ec2', 'route53_excluded_zones', '').split(','))
# Cache related
cache_path = config.get('ec2', 'cache_path')
@@ -422,9 +425,8 @@ class Ec2Inventory(object):
r53_conn = route53.Route53Connection()
all_zones = r53_conn.get_zones()
- is_valid_zone = lambda zone: not zone.name in self.route53_excluded_zones
-
- route53_zones = filter(is_valid_zone, all_zones)
+ route53_zones = [ zone for zone in all_zones if zone.name[:-1]
+ not in self.route53_excluded_zones ]
self.route53_records = {}