From 5b17e5c9c3e504db2214387e765af1fa395912fe Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Wed, 5 Mar 2025 16:39:34 +0100 Subject: [PATCH] update: use singular form ANSIBLE_COLLECTIONS_PATH (#15841) * update: use singular form ANSIBLE_COLLECTIONS_PATH * update functional tests --- awx/main/tasks/jobs.py | 9 ++++----- .../tests/functional/test_inventory_source_injectors.py | 2 +- awx/playbooks/project_update.yml | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/awx/main/tasks/jobs.py b/awx/main/tasks/jobs.py index 339dc87261e9..ad9ceb016b67 100644 --- a/awx/main/tasks/jobs.py +++ b/awx/main/tasks/jobs.py @@ -917,7 +917,6 @@ def build_env(self, job, private_data_dir, private_data_files=None): env['ANSIBLE_NET_AUTH_PASS'] = network_cred.get_input('authorize_password', default='') path_vars = [ - ('ANSIBLE_COLLECTIONS_PATHS', 'collections_paths', 'requirements_collections', '~/.ansible/collections:/usr/share/ansible/collections'), ('ANSIBLE_ROLES_PATH', 'roles_path', 'requirements_roles', '~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles'), ('ANSIBLE_COLLECTIONS_PATH', 'collections_path', 'requirements_collections', '~/.ansible/collections:/usr/share/ansible/collections'), ] @@ -1520,7 +1519,7 @@ def build_env(self, inventory_update, private_data_dir, private_data_files=None) raise NotImplementedError('Cannot update file sources through the task system.') if inventory_update.source == 'scm' and inventory_update.source_project_update: - env_key = 'ANSIBLE_COLLECTIONS_PATHS' + env_key = 'ANSIBLE_COLLECTIONS_PATH' config_setting = 'collections_paths' folder = 'requirements_collections' default = '~/.ansible/collections:/usr/share/ansible/collections' @@ -1538,12 +1537,12 @@ def build_env(self, inventory_update, private_data_dir, private_data_files=None) paths = [config_values[config_setting]] + paths paths = [os.path.join(CONTAINER_ROOT, folder)] + paths env[env_key] = os.pathsep.join(paths) - if 'ANSIBLE_COLLECTIONS_PATHS' in env: - paths = env['ANSIBLE_COLLECTIONS_PATHS'].split(':') + if 'ANSIBLE_COLLECTIONS_PATH' in env: + paths = env['ANSIBLE_COLLECTIONS_PATH'].split(':') else: paths = ['~/.ansible/collections', '/usr/share/ansible/collections'] paths.append('/usr/share/automation-controller/collections') - env['ANSIBLE_COLLECTIONS_PATHS'] = os.pathsep.join(paths) + env['ANSIBLE_COLLECTIONS_PATH'] = os.pathsep.join(paths) return env diff --git a/awx/main/tests/functional/test_inventory_source_injectors.py b/awx/main/tests/functional/test_inventory_source_injectors.py index 4c01c0a4fba7..c7a8063a5166 100644 --- a/awx/main/tests/functional/test_inventory_source_injectors.py +++ b/awx/main/tests/functional/test_inventory_source_injectors.py @@ -231,7 +231,7 @@ def substitute_run(awx_receptor_job): len([True for k in content.keys() if k.endswith(inventory_filename)]) > 0 ), f"'{inventory_filename}' file not found in inventory update runtime files {content.keys()}" - env.pop('ANSIBLE_COLLECTIONS_PATHS', None) # collection paths not relevant to this test + env.pop('ANSIBLE_COLLECTIONS_PATH', None) base_dir = os.path.join(DATA, 'plugins') if not os.path.exists(base_dir): os.mkdir(base_dir) diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml index 2f4ab183c747..1cdf046106e2 100644 --- a/awx/playbooks/project_update.yml +++ b/awx/playbooks/project_update.yml @@ -201,7 +201,7 @@ # additional_galaxy_env contains environment variables are used for installing roles and collections and will take precedence over items in galaxy_task_env additional_galaxy_env: # These paths control where ansible-galaxy installs collections and roles on top the filesystem - ANSIBLE_COLLECTIONS_PATHS: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections" + ANSIBLE_COLLECTIONS_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections" ANSIBLE_ROLES_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles" # Put the local tmp directory in same volume as collection destination # otherwise, files cannot be moved accross volumes and will cause error