X-Git-Url: http://git.squeep.com/?p=awsible;a=blobdiff_plain;f=inventory%2Fasg-inventory.py;h=34c6e1c6f7ce8df1e44e85ca6416712fdd99ed6d;hp=1eba92e66e0b93813d267964bd5362dec2694193;hb=0180483a567b94edc9c3d5da75f5bec695740f7e;hpb=3e9071903ac30cc306ccd34372087c6492106e57 diff --git a/inventory/asg-inventory.py b/inventory/asg-inventory.py index 1eba92e..34c6e1c 100755 --- a/inventory/asg-inventory.py +++ b/inventory/asg-inventory.py @@ -9,13 +9,19 @@ import argparse import boto3 import json import sys +import os from multiprocessing.dummy import Pool as ThreadPool from functools import partial -DEFAULT_REGIONS = ['us-east-1', 'us-west-2'] +#DEFAULT_REGIONS = ['us-east-1', 'us-west-2'] +DEFAULT_REGIONS = ['us-east-2'] HOSTVARS = {} +try: + PUBLIC = len(os.environ['INVENTORY_PUBLIC']) > 0 +except: + PUBLIC = False def allASGInstances(asgc): 'Return a tuple of a dict of each ASG name listing the instance IDs within it, and a list of all instance IDs.' @@ -84,7 +90,7 @@ def mergeDictOfLists(a, b): parser = argparse.ArgumentParser(description='dynamic Ansible inventory from AWS Autoscaling Groups') -parser.add_argument('--public', action='store_true', help='inventory public IPs (default: private IPs)') +parser.add_argument('--public', action='store_true' if not PUBLIC else 'store_false', help='inventory public IPs (default: private IPs)') parser.add_argument('--profile', metavar='PROFILE', dest='profile_name', help='AWS Profile (default: current IAM Role)') parser.add_argument('--regions', metavar='REGION', nargs='+', default=DEFAULT_REGIONS, help='AWS Regions (default: %(default)s)') parser.add_argument('--list', action='store_true')