Compare commits

..

1 Commits

Author SHA1 Message Date
Peter Braun
293abc8b35 fix: make indirect host counting live test more reliable 2025-03-04 23:00:50 +01:00
5 changed files with 17 additions and 8 deletions

View File

@@ -917,6 +917,7 @@ class RunJob(SourceControlMixin, BaseTask):
env['ANSIBLE_NET_AUTH_PASS'] = network_cred.get_input('authorize_password', default='') env['ANSIBLE_NET_AUTH_PASS'] = network_cred.get_input('authorize_password', default='')
path_vars = [ 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_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'), ('ANSIBLE_COLLECTIONS_PATH', 'collections_path', 'requirements_collections', '~/.ansible/collections:/usr/share/ansible/collections'),
] ]
@@ -1519,7 +1520,7 @@ class RunInventoryUpdate(SourceControlMixin, BaseTask):
raise NotImplementedError('Cannot update file sources through the task system.') raise NotImplementedError('Cannot update file sources through the task system.')
if inventory_update.source == 'scm' and inventory_update.source_project_update: if inventory_update.source == 'scm' and inventory_update.source_project_update:
env_key = 'ANSIBLE_COLLECTIONS_PATH' env_key = 'ANSIBLE_COLLECTIONS_PATHS'
config_setting = 'collections_paths' config_setting = 'collections_paths'
folder = 'requirements_collections' folder = 'requirements_collections'
default = '~/.ansible/collections:/usr/share/ansible/collections' default = '~/.ansible/collections:/usr/share/ansible/collections'
@@ -1537,12 +1538,12 @@ class RunInventoryUpdate(SourceControlMixin, BaseTask):
paths = [config_values[config_setting]] + paths paths = [config_values[config_setting]] + paths
paths = [os.path.join(CONTAINER_ROOT, folder)] + paths paths = [os.path.join(CONTAINER_ROOT, folder)] + paths
env[env_key] = os.pathsep.join(paths) env[env_key] = os.pathsep.join(paths)
if 'ANSIBLE_COLLECTIONS_PATH' in env: if 'ANSIBLE_COLLECTIONS_PATHS' in env:
paths = env['ANSIBLE_COLLECTIONS_PATH'].split(':') paths = env['ANSIBLE_COLLECTIONS_PATHS'].split(':')
else: else:
paths = ['~/.ansible/collections', '/usr/share/ansible/collections'] paths = ['~/.ansible/collections', '/usr/share/ansible/collections']
paths.append('/usr/share/automation-controller/collections') paths.append('/usr/share/automation-controller/collections')
env['ANSIBLE_COLLECTIONS_PATH'] = os.pathsep.join(paths) env['ANSIBLE_COLLECTIONS_PATHS'] = os.pathsep.join(paths)
return env return env

View File

@@ -231,7 +231,7 @@ def test_inventory_update_injected_content(product_name, this_kind, inventory, f
len([True for k in content.keys() if k.endswith(inventory_filename)]) > 0 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()}" ), f"'{inventory_filename}' file not found in inventory update runtime files {content.keys()}"
env.pop('ANSIBLE_COLLECTIONS_PATH', None) env.pop('ANSIBLE_COLLECTIONS_PATHS', None) # collection paths not relevant to this test
base_dir = os.path.join(DATA, 'plugins') base_dir = os.path.join(DATA, 'plugins')
if not os.path.exists(base_dir): if not os.path.exists(base_dir):
os.mkdir(base_dir) os.mkdir(base_dir)

View File

@@ -49,7 +49,15 @@ def test_indirect_host_counting(live_tmp_folder, run_job_from_playbook):
# Task might not run due to race condition, so make it run here # Task might not run due to race condition, so make it run here
job.refresh_from_db() job.refresh_from_db()
if job.event_queries_processed is False: if job.event_queries_processed is False:
save_indirect_host_entries.delay(job.id, wait_for_events=False) for _ in range(10):
save_indirect_host_entries.delay(job.id, wait_for_events=True)
job.refresh_from_db()
if job.event_queries_processed is True:
break
time.sleep(0.5)
else:
raise RuntimeError(f'Job events not received for job_id={job.id}')
# This will poll for the background task to finish # This will poll for the background task to finish
for _ in range(10): for _ in range(10):
if IndirectManagedNodeAudit.objects.filter(job=job).exists(): if IndirectManagedNodeAudit.objects.filter(job=job).exists():

View File

@@ -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 contains environment variables are used for installing roles and collections and will take precedence over items in galaxy_task_env
additional_galaxy_env: additional_galaxy_env:
# These paths control where ansible-galaxy installs collections and roles on top the filesystem # These paths control where ansible-galaxy installs collections and roles on top the filesystem
ANSIBLE_COLLECTIONS_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections" ANSIBLE_COLLECTIONS_PATHS: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_collections"
ANSIBLE_ROLES_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles" ANSIBLE_ROLES_PATH: "{{ projects_root }}/.__awx_cache/{{ local_path }}/stage/requirements_roles"
# Put the local tmp directory in same volume as collection destination # Put the local tmp directory in same volume as collection destination
# otherwise, files cannot be moved accross volumes and will cause error # otherwise, files cannot be moved accross volumes and will cause error

View File

@@ -1,6 +1,6 @@
git+https://github.com/ansible/system-certifi.git@devel#egg=certifi git+https://github.com/ansible/system-certifi.git@devel#egg=certifi
# Remove pbr from requirements.in when moving ansible-runner to requirements.in # Remove pbr from requirements.in when moving ansible-runner to requirements.in
git+https://github.com/demonpig/ansible-runner.git@AAP-37599#egg=ansible-runner git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner
django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac,feature-flags] django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac,feature-flags]
awx-plugins-core @ git+https://github.com/ansible/awx-plugins.git@devel#egg=awx-plugins-core[credentials-github-app] awx-plugins-core @ git+https://github.com/ansible/awx-plugins.git@devel#egg=awx-plugins-core[credentials-github-app]
awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git