diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 2355b04039..8dcdb3d573 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -114,6 +114,9 @@ class WorkflowNodeBase(CreatedModifiedModel, LaunchTimeConfig): 'credentials', 'char_prompts', 'all_parents_must_converge', + 'labels', + 'instance_groups', + 'execution_environment', ] def create_workflow_job_node(self, **kwargs): @@ -122,7 +125,7 @@ class WorkflowNodeBase(CreatedModifiedModel, LaunchTimeConfig): """ create_kwargs = {} for field_name in self._get_workflow_job_field_names(): - if field_name == 'credentials': + if field_name in ['credentials', 'labels', 'instance_groups']: continue if field_name in kwargs: create_kwargs[field_name] = kwargs[field_name] @@ -132,10 +135,20 @@ class WorkflowNodeBase(CreatedModifiedModel, LaunchTimeConfig): new_node = WorkflowJobNode.objects.create(**create_kwargs) if self.pk: allowed_creds = self.credentials.all() + allowed_labels = self.labels.all() + allowed_instance_groups = self.instance_groups.all() else: allowed_creds = [] + allowed_labels = [] + allowed_instance_groups = [] for cred in allowed_creds: new_node.credentials.add(cred) + + for label in allowed_labels: + new_node.labels.add(label) + for instance_group in allowed_instance_groups: + new_node.instance_groups.add(instance_group) + return new_node diff --git a/awx/main/tests/unit/models/test_workflow_unit.py b/awx/main/tests/unit/models/test_workflow_unit.py index 65190f92a3..dc01c3301f 100644 --- a/awx/main/tests/unit/models/test_workflow_unit.py +++ b/awx/main/tests/unit/models/test_workflow_unit.py @@ -166,6 +166,7 @@ class TestWorkflowJobCreate: unified_job_template=wfjt_node_no_prompts.unified_job_template, workflow_job=workflow_job_unit, identifier=mocker.ANY, + execution_environment=None, ) def test_create_with_prompts(self, wfjt_node_with_prompts, workflow_job_unit, credential, mocker): @@ -181,6 +182,7 @@ class TestWorkflowJobCreate: unified_job_template=wfjt_node_with_prompts.unified_job_template, workflow_job=workflow_job_unit, identifier=mocker.ANY, + execution_environment=None, )