mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 21:30:22 -07:00
Added warnings to command module
Generate warnings when users are shelling out to commands rather than using modules Can be turned off on a per-action line with the documented warn=False flag. Can be turned off globally using command_warnings = False in ansible config file. Print out warnings using the standard playbook callbacks. Created some additional tests in TestRunner.test_command and also a demonstration playbook.
This commit is contained in:
parent
f54665aa51
commit
ab8490d003
5 changed files with 68 additions and 17 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue