diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index 536ac8a912..54269fff1e 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -209,6 +209,9 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin): self.name = Truncator(u': '.join(filter(None, (self.module_name, self.module_args)))).chars(512) if 'name' not in update_fields: update_fields.append('name') + if not self.execution_environment_id: + self.execution_environment = self.resolve_execution_environment() + update_fields.append('execution_environment') super(AdHocCommand, self).save(*args, **kwargs) @property diff --git a/awx/main/tasks.py b/awx/main/tasks.py index d0a78064af..cf081a9d17 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -888,8 +888,11 @@ class BaseTask(object): def build_execution_environment_params(self, instance): if instance.execution_environment_id is None: - self.instance = instance = self.update_model( - instance.pk, execution_environment=instance.resolve_execution_environment()) + from awx.main.signals import disable_activity_stream + + with disable_activity_stream(): + self.instance = instance = self.update_model( + instance.pk, execution_environment=instance.resolve_execution_environment()) image = instance.execution_environment.image params = {