adds Playbook & AdHoc Diff

This commit is contained in:
adamscmRH
2017-07-06 16:33:06 -04:00
parent d57bc3b59c
commit ecef799a5a
4 changed files with 12 additions and 4 deletions

View File

@@ -2585,7 +2585,7 @@ class AdHocCommandSerializer(UnifiedJobSerializer):
model = AdHocCommand model = AdHocCommand
fields = ('*', 'job_type', 'inventory', 'limit', 'credential', fields = ('*', 'job_type', 'inventory', 'limit', 'credential',
'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars', 'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars',
'become_enabled', '-unified_job_template', '-description') 'become_enabled', 'diff_mode', '-unified_job_template', '-description')
extra_kwargs = { extra_kwargs = {
'name': { 'name': {
'read_only': True, 'read_only': True,

View File

@@ -21,4 +21,9 @@ class Migration(migrations.Migration):
name='diff_mode', name='diff_mode',
field=models.BooleanField(default=False), field=models.BooleanField(default=False),
), ),
migrations.AddField(
model_name='adhoccommand',
name='diff_mode',
field=models.BooleanField(default=False),
),
] ]

View File

@@ -34,6 +34,9 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin):
class Meta(object): class Meta(object):
app_label = 'main' app_label = 'main'
diff_mode = models.BooleanField(
default=False,
)
job_type = models.CharField( job_type = models.CharField(
max_length=64, max_length=64,
choices=AD_HOC_JOB_TYPE_CHOICES, choices=AD_HOC_JOB_TYPE_CHOICES,
@@ -195,7 +198,7 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin):
data = {} data = {}
for field in ('job_type', 'inventory_id', 'limit', 'credential_id', for field in ('job_type', 'inventory_id', 'limit', 'credential_id',
'module_name', 'module_args', 'forks', 'verbosity', 'module_name', 'module_args', 'forks', 'verbosity',
'extra_vars', 'become_enabled'): 'extra_vars', 'become_enabled', 'diff_mode'):
data[field] = getattr(self, field) data[field] = getattr(self, field)
return AdHocCommand.objects.create(**data) return AdHocCommand.objects.create(**data)

View File

@@ -2011,10 +2011,10 @@ class RunAdHocCommand(BaseTask):
if ad_hoc_command.forks: # FIXME: Max limit? if ad_hoc_command.forks: # FIXME: Max limit?
args.append('--forks=%d' % ad_hoc_command.forks) args.append('--forks=%d' % ad_hoc_command.forks)
if ad_hoc_command.diff_mode:
args.append('--diff')
if ad_hoc_command.verbosity: if ad_hoc_command.verbosity:
args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity))) args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity)))
# if ad_hoc_command.diff_mode:
# args.append('--diff')
if ad_hoc_command.extra_vars_dict: if ad_hoc_command.extra_vars_dict:
args.extend(['-e', json.dumps(ad_hoc_command.extra_vars_dict)]) args.extend(['-e', json.dumps(ad_hoc_command.extra_vars_dict)])