diff --git a/CHANGELOG.md b/CHANGELOG.md index 764fccfc3a..1709dafce4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ New core features: * 'ansible vault view filename.yml' opens filename.yml decrypted in a pager. * no_log parameter now surpressess data from callbacks/output as well as syslog * ansible-galaxy install -f requirements.yml allows advanced options and installs from non-galaxy SCM sources and tarballs. -* command_warnings feature will warn about when usage of the shell/command module can be simplified to use core modules - this can be disabled in ansible.cfg +* command_warnings feature will warn about when usage of the shell/command module can be simplified to use core modules - this can be enabled in ansible.cfg New Modules: diff --git a/examples/ansible.cfg b/examples/ansible.cfg index 9113472406..4bee138ec8 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -102,12 +102,13 @@ ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} # to disable these warnings, set the following value to False: #deprecation_warnings = True -# by default (as of 1.8), Ansible will warn when usage of the shell and +# (as of 1.8), Ansible can optionally warn when usage of the shell and # command module appear to be simplified by using a default Ansible module # instead. These warnings can be silenced by adjusting the following # setting or adding warn=yes or warn=no to the end of the command line -# parameter string. -# command_warnings = True +# parameter string. This will for example suggest using the git module +# instead of shelling out to the git command. +# command_warnings = False # set plugin path directories here, separate with colons diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 269f116134..8025706dad 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -170,7 +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) +COMMAND_WARNINGS = get_config(p, DEFAULTS, 'command_warnings', 'ANSIBLE_COMMAND_WARNINGS', False, 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 8071adbc49..c1fabd4f9b 100644 --- a/library/commands/command +++ b/library/commands/command @@ -71,10 +71,9 @@ options: version_added: "1.8" default: yes description: - - "turn off warnings about running a command that is provided by an Ansible module, suggesting you should use that module instead. 'Command warnings' can also be turned off globally in ansible.cfg" + - if command warnings are on in ansible.cfg, do not warn about this particular line if set to no/false. 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 diff --git a/library/commands/shell b/library/commands/shell index 7911963e2c..b63a21080e 100644 --- a/library/commands/shell +++ b/library/commands/shell @@ -43,10 +43,10 @@ options: version_added: "0.9" warn: description: - - turn off warnings about running a command that is provided by an Ansible module. + - if command warnings are on in ansible.cfg, do not warn about this particular line if set to no/false. required: false default: True - version_added: "1.5" + version_added: "1.8" notes: - If you want to execute a command securely and predictably, it may be better to use the M(command) module instead. Best practices when writing