Deprecate command warnings feature (#70504)
Change: - The command warnings feature which suggests that users use modules instead of certain commands is now deprecated. Its `warn` paramater and `COMMAND_WARNINGS` configuration options are also deprecated. Their use will become an error in version 2.13. Test Plan: - CI Signed-off-by: Rick Elrod <rick@elrod.me> Co-authored-by: Sam Doran <sdoran@redhat.com>
This commit is contained in:
parent
707458cc8c
commit
41414ed475
4 changed files with 14 additions and 58 deletions
2
changelogs/fragments/command-warnings-deprecation.yml
Normal file
2
changelogs/fragments/command-warnings-deprecation.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
deprecated_features:
|
||||
- Starting in 2.14, shell and command modules will no longer have the option to warn and suggest modules in lieu of commands. The ``warn`` parameter to these modules is now deprecated and defaults to ``False``. Similarly, the ``COMMAND_WARNINGS`` configuration option is also deprecated and defaults to ``False``. These will be removed and their presence will become an error in 2.14.
|
|
@ -416,15 +416,20 @@ ACTION_WARNINGS:
|
|||
version_added: "2.5"
|
||||
COMMAND_WARNINGS:
|
||||
name: Command module warnings
|
||||
default: True
|
||||
default: False
|
||||
description:
|
||||
- By default Ansible will issue a warning when the shell or command module is used and the command appears to be similar to an existing Ansible module.
|
||||
- Ansible can issue a warning when the shell or command module is used and the command appears to be similar to an existing Ansible module.
|
||||
- These warnings can be silenced by adjusting this setting to False. You can also control this at the task level with the module option ``warn``.
|
||||
- As of version 2.11, this is disabled by default.
|
||||
env: [{name: ANSIBLE_COMMAND_WARNINGS}]
|
||||
ini:
|
||||
- {key: command_warnings, section: defaults}
|
||||
type: boolean
|
||||
version_added: "1.8"
|
||||
deprecated:
|
||||
why: The command warnings feature is being removed.
|
||||
version: "2.14"
|
||||
alternatives: N/A, these are just warnings and we no longer plan to show them.
|
||||
LOCALHOST_WARNING:
|
||||
name: Warning when using implicit inventory with only localhost
|
||||
default: True
|
||||
|
|
|
@ -58,9 +58,11 @@ options:
|
|||
version_added: "0.6"
|
||||
warn:
|
||||
description:
|
||||
- Enable or disable task warnings.
|
||||
- (deprecated) Enable or disable task warnings.
|
||||
- This feature is deprecated and will be removed in 2.14.
|
||||
- As of version 2.11, this option is now disabled by default.
|
||||
type: bool
|
||||
default: yes
|
||||
default: no
|
||||
version_added: "1.8"
|
||||
stdin:
|
||||
description:
|
||||
|
@ -259,7 +261,7 @@ def main():
|
|||
creates=dict(type='path'),
|
||||
removes=dict(type='path'),
|
||||
# The default for this really comes from the action plugin
|
||||
warn=dict(type='bool', default=True),
|
||||
warn=dict(type='bool', default=False, removed_in_version='2.14', removed_from_collection='ansible.builtin'),
|
||||
stdin=dict(required=False),
|
||||
stdin_add_newline=dict(type='bool', default=True),
|
||||
strip_empty_ends=dict(type='bool', default=True),
|
||||
|
|
|
@ -3,46 +3,6 @@
|
|||
# Copyright: (c) 2014, Richard Isaacson <richard.c.isaacson@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: use command to execute sudo
|
||||
command: sudo -h
|
||||
register: become
|
||||
|
||||
- name: assert become warning was reported
|
||||
assert:
|
||||
that:
|
||||
- "become.warnings | length() == 1"
|
||||
- "'Consider using' in become.warnings[0]"
|
||||
|
||||
- name: use command to execute sudo without warnings
|
||||
command: sudo -h warn=no
|
||||
register: become
|
||||
|
||||
- name: assert become warning was not reported
|
||||
assert:
|
||||
that:
|
||||
- "'warnings' not in become"
|
||||
|
||||
- name: use command to execute tar
|
||||
command: tar --help
|
||||
register: tar
|
||||
|
||||
- name: assert tar warning was reported
|
||||
assert:
|
||||
that:
|
||||
- tar.warnings | length() == 1
|
||||
- '"Consider using the unarchive module rather than running ''tar''" in tar.warnings[0]'
|
||||
|
||||
- name: use command to execute chown
|
||||
command: chown -h
|
||||
register: chown
|
||||
ignore_errors: true
|
||||
|
||||
- name: assert chown warning was reported
|
||||
assert:
|
||||
that:
|
||||
- chown.warnings | length() == 1
|
||||
- '"Consider using the file module with owner rather than running ''chown''" in chown.warnings[0]'
|
||||
|
||||
- name: use command with unsupported executable arg
|
||||
command: ls /dev/null
|
||||
args:
|
||||
|
@ -56,19 +16,6 @@
|
|||
- executable.warnings | length() == 1
|
||||
- "'no longer supported' in executable.warnings[0]"
|
||||
|
||||
# The warning isn't on the task since it comes from the action plugin. Not sure
|
||||
# how to test for that.
|
||||
#
|
||||
# - name: Use command with reboot
|
||||
# command: sleep 2 && /not/shutdown -r now
|
||||
# ignore_errors: yes
|
||||
# register: reboot
|
||||
|
||||
# - name: Assert that reboot warning was issued
|
||||
# assert:
|
||||
# that:
|
||||
# - '"Consider using the reboot module" in reboot.warnings[0]'
|
||||
|
||||
- name: use command with no command
|
||||
command:
|
||||
args:
|
||||
|
|
Loading…
Reference in a new issue