From ecef799a5a0457ade5b70ab1706e4d8fd96df833 Mon Sep 17 00:00:00 2001 From: adamscmRH Date: Thu, 6 Jul 2017 16:33:06 -0400 Subject: [PATCH] adds Playbook & AdHoc Diff --- awx/api/serializers.py | 2 +- awx/main/migrations/0044_v320_diff_mode.py | 5 +++++ awx/main/models/ad_hoc_commands.py | 5 ++++- awx/main/tasks.py | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 604905c240..b7bca2329d 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2585,7 +2585,7 @@ class AdHocCommandSerializer(UnifiedJobSerializer): model = AdHocCommand fields = ('*', 'job_type', 'inventory', 'limit', 'credential', 'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars', - 'become_enabled', '-unified_job_template', '-description') + 'become_enabled', 'diff_mode', '-unified_job_template', '-description') extra_kwargs = { 'name': { 'read_only': True, diff --git a/awx/main/migrations/0044_v320_diff_mode.py b/awx/main/migrations/0044_v320_diff_mode.py index dd0a766f9c..f27f96f605 100644 --- a/awx/main/migrations/0044_v320_diff_mode.py +++ b/awx/main/migrations/0044_v320_diff_mode.py @@ -21,4 +21,9 @@ class Migration(migrations.Migration): name='diff_mode', field=models.BooleanField(default=False), ), + migrations.AddField( + model_name='adhoccommand', + name='diff_mode', + field=models.BooleanField(default=False), + ), ] diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index d5662c7faa..b18c23d7f3 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -34,6 +34,9 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin): class Meta(object): app_label = 'main' + diff_mode = models.BooleanField( + default=False, + ) job_type = models.CharField( max_length=64, choices=AD_HOC_JOB_TYPE_CHOICES, @@ -195,7 +198,7 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin): data = {} for field in ('job_type', 'inventory_id', 'limit', 'credential_id', 'module_name', 'module_args', 'forks', 'verbosity', - 'extra_vars', 'become_enabled'): + 'extra_vars', 'become_enabled', 'diff_mode'): data[field] = getattr(self, field) return AdHocCommand.objects.create(**data) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 9736147bc8..a20db257c3 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -2011,10 +2011,10 @@ class RunAdHocCommand(BaseTask): if ad_hoc_command.forks: # FIXME: Max limit? args.append('--forks=%d' % ad_hoc_command.forks) + if ad_hoc_command.diff_mode: + args.append('--diff') if 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: args.extend(['-e', json.dumps(ad_hoc_command.extra_vars_dict)])