diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 058b31f80b..1a471a265d 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -264,12 +264,13 @@ class WorkflowJobNode(WorkflowNodeBase): data['survey_passwords'] = password_dict # process extra_vars extra_vars = data.get('extra_vars', {}) - if aa_dict: - functional_aa_dict = copy(aa_dict) - functional_aa_dict.pop('_ansible_no_log', None) - extra_vars.update(functional_aa_dict) - # Workflow Job extra_vars higher precedence than ancestor artifacts + if ujt_obj and isinstance(ujt_obj, (JobTemplate, WorkflowJobTemplate)): + if aa_dict: + functional_aa_dict = copy(aa_dict) + functional_aa_dict.pop('_ansible_no_log', None) + extra_vars.update(functional_aa_dict) if ujt_obj and isinstance(ujt_obj, JobTemplate): + # Workflow Job extra_vars higher precedence than ancestor artifacts if self.workflow_job and self.workflow_job.extra_vars: extra_vars.update(self.workflow_job.extra_vars_dict) if extra_vars: diff --git a/awx/main/tests/functional/models/test_workflow.py b/awx/main/tests/functional/models/test_workflow.py index 41c8be70e3..3b61e6c29b 100644 --- a/awx/main/tests/functional/models/test_workflow.py +++ b/awx/main/tests/functional/models/test_workflow.py @@ -186,7 +186,7 @@ class TestWorkflowJob: assert nodes[0].failure_nodes.filter(id=nodes[3].id).exists() assert nodes[3].failure_nodes.filter(id=nodes[4].id).exists() - def test_inherit_ancestor_artifacts_from_job(self, project, mocker): + def test_inherit_ancestor_artifacts_from_job(self, job_template, mocker): """ Assure that nodes along the line of execution inherit artifacts from both jobs ran, and from the accumulation of old jobs @@ -197,13 +197,13 @@ class TestWorkflowJob: # Workflow job nodes job_node = WorkflowJobNode.objects.create(workflow_job=wfj, job=job, ancestor_artifacts={'a': 42}) - queued_node = WorkflowJobNode.objects.create(workflow_job=wfj) + queued_node = WorkflowJobNode.objects.create(workflow_job=wfj, unified_job_template=job_template) # Connect old job -> new job mocker.patch.object(queued_node, 'get_parent_nodes', lambda: [job_node]) assert queued_node.get_job_kwargs()['extra_vars'] == {'a': 42, 'b': 43} assert queued_node.ancestor_artifacts == {'a': 42, 'b': 43} - def test_inherit_ancestor_artifacts_from_project_update(self, project, mocker): + def test_inherit_ancestor_artifacts_from_project_update(self, project, job_template, mocker): """ Test that the existence of a project update (no artifacts) does not break the flow of ancestor_artifacts @@ -214,7 +214,7 @@ class TestWorkflowJob: # Workflow job nodes project_node = WorkflowJobNode.objects.create(workflow_job=wfj, job=update, ancestor_artifacts={'a': 42, 'b': 43}) - queued_node = WorkflowJobNode.objects.create(workflow_job=wfj) + queued_node = WorkflowJobNode.objects.create(workflow_job=wfj, unified_job_template=job_template) # Connect project update -> new job mocker.patch.object(queued_node, 'get_parent_nodes', lambda: [project_node]) assert queued_node.get_job_kwargs()['extra_vars'] == {'a': 42, 'b': 43}