mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 11:55:04 -02:30
Include ec2 inventory changes from https://github.com/ansible/ansible/pull/8010 and https://github.com/ansible/ansible/pull/8119
This commit is contained in:
@@ -222,6 +222,16 @@ class Ec2Inventory(object):
|
||||
self.route53_excluded_zones.extend(
|
||||
config.get('ec2', 'route53_excluded_zones', '').split(','))
|
||||
|
||||
# Return all EC2/RDS instances
|
||||
if config.has_option('ec2', 'all_instances'):
|
||||
self.all_instances = config.getboolean('ec2', 'all_instances')
|
||||
else:
|
||||
self.all_instances = False
|
||||
if config.has_option('ec2', 'all_rds_instances'):
|
||||
self.all_rds_instances = config.getboolean('ec2', 'all_rds_instances')
|
||||
else:
|
||||
self.all_rds_instances = False
|
||||
|
||||
# Cache related
|
||||
cache_dir = os.path.expanduser(config.get('ec2', 'cache_path'))
|
||||
if not os.path.exists(cache_dir):
|
||||
@@ -292,7 +302,7 @@ class Ec2Inventory(object):
|
||||
sys.exit(1)
|
||||
|
||||
def get_rds_instances_by_region(self, region):
|
||||
''' Makes an AWS API call to the list of RDS instances in a particular
|
||||
''' Makes an AWS API call to the list of RDS instances in a particular
|
||||
region '''
|
||||
|
||||
try:
|
||||
@@ -329,10 +339,9 @@ class Ec2Inventory(object):
|
||||
''' Adds an instance to the inventory and index, as long as it is
|
||||
addressable '''
|
||||
|
||||
# For Ansible Tower, return all instances regardless of state.
|
||||
# Only want running instances
|
||||
#if instance.state != 'running':
|
||||
# return
|
||||
# Only want running instances unless all_instances is True
|
||||
if not self.all_instances and instance.state != 'running':
|
||||
return
|
||||
|
||||
# Select the best destination address
|
||||
if instance.subnet_id:
|
||||
@@ -412,8 +421,8 @@ class Ec2Inventory(object):
|
||||
''' Adds an RDS instance to the inventory and index, as long as it is
|
||||
addressable '''
|
||||
|
||||
# Only want available instances
|
||||
if instance.status != 'available':
|
||||
# Only want available instances unless all_rds_instances is True
|
||||
if not self.all_rds_instances and instance.status != 'available':
|
||||
return
|
||||
|
||||
# Select the best destination address
|
||||
|
||||
Reference in New Issue
Block a user