From 456d2627e86df36b7be89d7e4ae798debe9f1712 Mon Sep 17 00:00:00 2001 From: Ingmar Hupp Date: Thu, 27 Mar 2014 15:57:24 +0000 Subject: [PATCH 1/2] EC2 inventory toggle to exclude/include RDS instances. --- plugins/inventory/ec2.ini | 3 +++ plugins/inventory/ec2.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/inventory/ec2.ini b/plugins/inventory/ec2.ini index b931c4a7da9..90c09df1a71 100644 --- a/plugins/inventory/ec2.ini +++ b/plugins/inventory/ec2.ini @@ -38,6 +38,9 @@ vpc_destination_variable = ip_address # Route53, uncomment and set 'route53' to True. route53 = False +# To include RDS instances in inventory, set to True. +rds = False + # Additionally, you can specify the list of zones to exclude looking up in # 'route53_excluded_zones' as a comma-separated list. # route53_excluded_zones = samplezone1.com, samplezone2.com diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index 84841d3f09a..b6d6765fbe2 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -222,6 +222,9 @@ class Ec2Inventory(object): self.route53_excluded_zones.extend( config.get('ec2', 'route53_excluded_zones', '').split(',')) + # RDS + self.rds_enabled = config.getboolean('ec2', 'rds') + # Cache related cache_dir = os.path.expanduser(config.get('ec2', 'cache_path')) if not os.path.exists(cache_dir): @@ -254,7 +257,8 @@ class Ec2Inventory(object): for region in self.regions: self.get_instances_by_region(region) - self.get_rds_instances_by_region(region) + if self.rds_enabled: + self.get_rds_instances_by_region(region) self.write_to_cache(self.inventory, self.cache_path_cache) self.write_to_cache(self.index, self.cache_path_index) From cc01f7b7f5e9a02a7e6c7ddfbdff1f37c0c5838e Mon Sep 17 00:00:00 2001 From: Ingmar Hupp Date: Thu, 27 Mar 2014 18:58:46 +0000 Subject: [PATCH 2/2] Do not filter out RDS instances by default or in INI file to avoid changing current behaviour. --- plugins/inventory/ec2.ini | 4 ++-- plugins/inventory/ec2.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/inventory/ec2.ini b/plugins/inventory/ec2.ini index 90c09df1a71..8a4e711aab2 100644 --- a/plugins/inventory/ec2.ini +++ b/plugins/inventory/ec2.ini @@ -38,8 +38,8 @@ vpc_destination_variable = ip_address # Route53, uncomment and set 'route53' to True. route53 = False -# To include RDS instances in inventory, set to True. -rds = False +# To exclude RDS instances from the inventory, uncomment and set to False. +#rds = False # Additionally, you can specify the list of zones to exclude looking up in # 'route53_excluded_zones' as a comma-separated list. diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index b6d6765fbe2..275e07505d8 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -223,7 +223,9 @@ class Ec2Inventory(object): config.get('ec2', 'route53_excluded_zones', '').split(',')) # RDS - self.rds_enabled = config.getboolean('ec2', 'rds') + self.rds_enabled = True + if config.has_option('ec2', 'rds'): + self.rds_enabled = config.getboolean('ec2', 'rds') # Cache related cache_dir = os.path.expanduser(config.get('ec2', 'cache_path'))