From 2291163a7a37876fde2b63746ca52aeba0bb7e2a Mon Sep 17 00:00:00 2001 From: Andrea Tartaglia Date: Wed, 16 Nov 2016 10:38:43 +0000 Subject: [PATCH] Added DIFF_ALWAYS constant When set to True, will always print the diff. Defaults to False. Fixes #18416 #16073 --- examples/ansible.cfg | 8 ++++++++ lib/ansible/constants.py | 1 + lib/ansible/playbook/play_context.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/ansible.cfg b/examples/ansible.cfg index 416b48b3d9..fd5ed9badc 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -387,3 +387,11 @@ #diff_add = green #diff_remove = red #diff_lines = cyan + + +[diff] +# Always print diff when running ( same as always running with -D/--diff ) +# always = no + +# Set how many context lines to show in diff +# context = 3 diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 2f5708d7bd..29d2ec1acf 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -383,6 +383,7 @@ COLOR_DIFF_LINES = get_config(p, 'colors', 'diff_lines', 'ANSIBLE_COLOR_DIFF_LI # diff DIFF_CONTEXT = get_config(p, 'diff', 'context', 'ANSIBLE_DIFF_CONTEXT', 3, value_type='integer') +DIFF_ALWAYS = get_config(p, 'diff', 'always', 'ANSIBLE_DIFF_ALWAYS', False, value_type='bool') # non-configurable things MODULE_REQUIRE_ARGS = ['command', 'win_command', 'net_command', 'shell', 'win_shell', 'raw', 'script'] diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index 0a611cf87b..6d3a447e5e 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -209,7 +209,7 @@ class PlayContext(Base): _force_handlers = FieldAttribute(isa='bool', default=False) _start_at_task = FieldAttribute(isa='string') _step = FieldAttribute(isa='bool', default=False) - _diff = FieldAttribute(isa='bool', default=False) + _diff = FieldAttribute(isa='bool', default=C.DIFF_ALWAYS) # Fact gathering settings _gather_subset = FieldAttribute(isa='string', default=C.DEFAULT_GATHER_SUBSET)