diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 433c7fb2f8..80ae17d474 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1893,6 +1893,19 @@ class RunJob(BaseTask): return False return getattr(settings, 'AWX_PROOT_ENABLED', False) + def build_execution_environment_params(self, instance): + params = super(RunJob, self).build_execution_environment_params(instance) + # If this has an insights agent and it is not already mounted then show it + insights_dir = os.path.dirname(settings.INSIGHTS_SYSTEM_ID_FILE) + if instance.use_fact_cache and os.path.exists(insights_dir): + logger.info('not parent of others') + params.setdefault('container_volume_mounts', []) + params['container_volume_mounts'].extend([ + f"{insights_dir}:{insights_dir}:Z", + ]) + + return params + def pre_run_hook(self, job, private_data_dir): super(RunJob, self).pre_run_hook(job, private_data_dir) if job.inventory is None: diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index b6631165a1..058d6aeaee 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -785,6 +785,8 @@ TOWER_URL_BASE = "https://towerhost" INSIGHTS_URL_BASE = "https://example.org" INSIGHTS_AGENT_MIME = 'application/example' +# See https://github.com/ansible/awx-facts-playbooks +INSIGHTS_SYSTEM_ID_FILE='/etc/redhat-access-insights/machine-id' TOWER_SETTINGS_MANIFEST = {}