From 7cce3cad06c9e02076625f9c49fa3af54320ccef Mon Sep 17 00:00:00 2001 From: Jim Ladd Date: Wed, 23 Jan 2019 17:25:51 -0800 Subject: [PATCH] Add support for ec2 inventory plugin --- awx/main/models/inventory.py | 12 ++++++++++++ awx/main/tasks.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 6b5a806fae..4e68e1009d 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1942,8 +1942,20 @@ class azure_rm(PluginFileInjector): class ec2(PluginFileInjector): + plugin_name = 'aws_ec2' + initial_version = '2.5' ini_env_reference = 'EC2_INI_PATH' + def inventory_as_dict(self, inventory_source): + ret = dict( + plugin='aws_ec2', + ) + # TODO: all regions currently failing due to: + # https://github.com/ansible/ansible/pull/48079 + if inventory_source.source_regions and 'all' not in inventory_source.source_regions: + ret['regions'] = inventory_source.source_regions.split(',') + return ret + def build_script_private_data(self, inventory_update, private_data_dir): cp = configparser.RawConfigParser() # Build custom ec2.ini for ec2 inventory script to use. diff --git a/awx/main/tasks.py b/awx/main/tasks.py index a3f031a800..fe5563445a 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -2071,7 +2071,7 @@ class RunInventoryUpdate(BaseTask): src = inventory_update.source if src in CLOUD_PROVIDERS: if src in InventorySource.injectors: - injector = InventorySource.injectors[inventory_update.source](self.get_ansible_version(inventory_update)) + injector = InventorySource.injectors[src](self.get_ansible_version(inventory_update)) if injector.should_use_plugin(): content = injector.inventory_contents(inventory_update, private_data_dir) # must be a statically named file