diff --git a/awx/main/tasks.py b/awx/main/tasks.py index f7c60fcad6..42e1087c6b 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1062,7 +1062,7 @@ class RunInventoryUpdate(BaseTask): pass elif inventory_update.source == 'custom': for env_k in inventory_update.source_vars_dict: - if str(env_k) not in os.environ and str(env_k) not in settings.INV_ENV_VARIABLE_BLACKLIST: + if str(env_k) not in env and str(env_k) not in settings.INV_ENV_VARIABLE_BLACKLIST: env[str(env_k)] = unicode(inventory_update.source_vars_dict[env_k]) return env diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index 6022ea8de8..9b18325671 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -1756,7 +1756,9 @@ class InventoryUpdatesTest(BaseTransactionTest): custom_inv_update = reverse('api:inventory_source_update_view', args=(custom_group.inventory_source.pk,)) inv_src_opts = {'source': 'custom', - 'source_script': script_data["id"]} + 'source_script': script_data["id"], + 'source_vars': json.dumps({'HOME': 'no-place-like', 'USER': 'notme', '_': 'nope', 'INVENTORY_SOURCE_ID': -1}) + } with self.current_user(self.super_django_user): response = self.put(custom_inv_src, inv_src_opts, expect=200) self.check_inventory_source(custom_group.inventory_source) diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 6dd120d9fc..ffd109faf2 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -351,7 +351,7 @@ RAX_GROUP_FILTER = r'^(?!instance-.+).+$' RAX_HOST_FILTER = r'^.+$' RAX_EXCLUDE_EMPTY_GROUPS = True -INV_ENV_VARIABLE_BLACKLIST = ("HOME", "_") +INV_ENV_VARIABLE_BLACKLIST = ("HOME", "USER", "_") # ---------------- # -- Amazon EC2 --