mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
restrict the running of jobs
The following jobs require a credential to launch * InventoryUpdate without custom script * Job * AdHocJob
This commit is contained in:
@@ -201,6 +201,17 @@ class AdHocCommand(UnifiedJob):
|
|||||||
update_fields.append('name')
|
update_fields.append('name')
|
||||||
super(AdHocCommand, self).save(*args, **kwargs)
|
super(AdHocCommand, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
# AdHocCommand Credential required
|
||||||
|
@property
|
||||||
|
def can_start(self):
|
||||||
|
if not super(AdHocCommand, self).can_start:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.credential and self.credential.active):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandEvent(CreatedModifiedModel):
|
class AdHocCommandEvent(CreatedModifiedModel):
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -1247,6 +1247,19 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions):
|
|||||||
def task_impact(self):
|
def task_impact(self):
|
||||||
return 50
|
return 50
|
||||||
|
|
||||||
|
# InventoryUpdate credential required
|
||||||
|
# Custom InventoryUpdate credential not required
|
||||||
|
@property
|
||||||
|
def can_start(self):
|
||||||
|
if not super(InventoryUpdate, self).can_start:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self.source != 'custom' \
|
||||||
|
and not (self.credential and self.credential.active):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class CustomInventoryScript(CommonModelNameNotUnique):
|
class CustomInventoryScript(CommonModelNameNotUnique):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -491,6 +491,17 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
presets[kw] = getattr(self, kw)
|
presets[kw] = getattr(self, kw)
|
||||||
return self.job_template.create_unified_job(**presets)
|
return self.job_template.create_unified_job(**presets)
|
||||||
|
|
||||||
|
# Job Credential required
|
||||||
|
@property
|
||||||
|
def can_start(self):
|
||||||
|
if not super(Job, self).can_start:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not (self.credential and self.credential.active):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class JobHostSummary(CreatedModifiedModel):
|
class JobHostSummary(CreatedModifiedModel):
|
||||||
'''
|
'''
|
||||||
Per-host statistics for each job.
|
Per-host statistics for each job.
|
||||||
|
|||||||
Reference in New Issue
Block a user