mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
Properly take prompted inventory into account
This also will rename shard jobs to add an index to the job name
This commit is contained in:
committed by
AlanCoding
parent
8a18984be1
commit
44ffcf86de
@@ -331,11 +331,17 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour
|
|||||||
kwargs['_unified_job_field_names'] = WorkflowJobTemplate._get_unified_job_field_names()
|
kwargs['_unified_job_field_names'] = WorkflowJobTemplate._get_unified_job_field_names()
|
||||||
job = self.create_unified_job(**kwargs)
|
job = self.create_unified_job(**kwargs)
|
||||||
if self.job_shard_count > 1:
|
if self.job_shard_count > 1:
|
||||||
for idx in xrange(self.job_shard_count):
|
if 'inventory' in kwargs:
|
||||||
|
actual_inventory = kwargs['inventory']
|
||||||
|
else:
|
||||||
|
actual_inventory = self.inventory
|
||||||
|
for idx in xrange(min(self.job_shard_count,
|
||||||
|
actual_inventory.hosts.count())):
|
||||||
create_kwargs = dict(workflow_job=job,
|
create_kwargs = dict(workflow_job=job,
|
||||||
unified_job_template=self,
|
unified_job_template=self,
|
||||||
#survey_passwords=self.survey_passwords,
|
#survey_passwords=self.survey_passwords,
|
||||||
inventory=self.inventory)
|
inventory=actual_inventory,
|
||||||
|
ancestor_artifacts=dict(job_shard=idx))
|
||||||
#char_prompts=self.char_prompts)
|
#char_prompts=self.char_prompts)
|
||||||
wfjn = WorkflowJobNode.objects.create(**create_kwargs)
|
wfjn = WorkflowJobNode.objects.create(**create_kwargs)
|
||||||
for cred in self.credentials.all():
|
for cred in self.credentials.all():
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ class TaskManager():
|
|||||||
continue
|
continue
|
||||||
kv = spawn_node.get_job_kwargs()
|
kv = spawn_node.get_job_kwargs()
|
||||||
job = spawn_node.unified_job_template.create_unified_job(**kv)
|
job = spawn_node.unified_job_template.create_unified_job(**kv)
|
||||||
|
if 'job_shard' in spawn_node.ancestor_artifacts:
|
||||||
|
job.name = "{} - {}".format(job.name, spawn_node.ancestor_artifacts['job_shard'] + 1)
|
||||||
|
job.save()
|
||||||
spawn_node.job = job
|
spawn_node.job = job
|
||||||
spawn_node.save()
|
spawn_node.save()
|
||||||
logger.info('Spawned %s in %s for node %s', job.log_format, workflow_job.log_format, spawn_node.pk)
|
logger.info('Spawned %s in %s for node %s', job.log_format, workflow_job.log_format, spawn_node.pk)
|
||||||
|
|||||||
Reference in New Issue
Block a user