diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 54c84a2420a..2fe34336261 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -535,6 +535,9 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): display(msg, color='green', runner=self.runner) else: display(msg, color='yellow', runner=self.runner) + if constants.COMMAND_WARNINGS and 'warnings' in host_result2 and host_result2['warnings']: + for warning in host_result2['warnings']: + display("warn: %s" % warning, color='purple', runner=self.runner) super(PlaybookRunnerCallbacks, self).on_ok(host, host_result) def on_skipped(self, host, item=None): diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index e69f25feef9..269f116134a 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -170,6 +170,7 @@ HOST_KEY_CHECKING = get_config(p, DEFAULTS, 'host_key_checking', ' SYSTEM_WARNINGS = get_config(p, DEFAULTS, 'system_warnings', 'ANSIBLE_SYSTEM_WARNINGS', True, boolean=True) DEPRECATION_WARNINGS = get_config(p, DEFAULTS, 'deprecation_warnings', 'ANSIBLE_DEPRECATION_WARNINGS', True, boolean=True) DEFAULT_CALLABLE_WHITELIST = get_config(p, DEFAULTS, 'callable_whitelist', 'ANSIBLE_CALLABLE_WHITELIST', [], islist=True) +COMMAND_WARNINGS = get_config(p, DEFAULTS, 'command_warnings', 'ANSIBLE_COMMAND_WARNINGS', True, boolean=True) # CONNECTION RELATED ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'ANSIBLE_SSH_ARGS', None) diff --git a/library/commands/command b/library/commands/command index dde2d645170..66abb759eeb 100644 --- a/library/commands/command +++ b/library/commands/command @@ -67,6 +67,12 @@ options: required: false default: null version_added: "0.9" + warn: + description: + - turn off warnings about running a command that is provided by an Ansible module. + required: false + default: True + version_added: "1.5" notes: - If you want to run a command through the shell (say you are using C(<), C(>), C(|), etc), you actually want the M(shell) module instead. The @@ -108,7 +114,27 @@ EXAMPLES = ''' # that was matched in the first 'quote' is found, or the end of # the line is reached -PARAM_REGEX = re.compile(r'(^|\s)(creates|removes|chdir|executable|NO_LOG)=(?P[\'"])?(.*?)(?(quote)(?[\'"])?(.*?)(?(quote)(?