Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible: Unsupported parameters for (ansible.legacy.command) module: warn

Tags:

ansible

Today I encountered an old part of our Ansible playbook failing:

Current situation

- name: Install something
  shell: somecomand
  args:
    warn: false

This throws fatal:

"msg": "Unsupported parameters for (ansible.legacy.command) module: warn. Supported parameters include: chdir, _raw_params, removes, stdin, argv, executable, strip_empty_ends, stdin_add_newline, creates, _uses_shell."

Apparently warn is no longer supported. I tried to find the "new" way to ignore warnings, but everything I found directed me towards the old warn: false method.

Question

What is the "new" way to ignore warning or - if a better way comes to mind: to fix this issue?

Ansible version

pip show ansible
Name: ansible
Version: 7.0.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.10/dist-packages
Requires: ansible-core
Required-by:

The same playbook runs without issues under:

pip show ansible
Name: ansible
Version: 6.6.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /home/ubuntu/.local/lib/python3.10/site-packages
Requires: ansible-core
Required-by: 
like image 581
Natan Avatar asked Sep 09 '25 19:09

Natan


1 Answers

The warn parameter for shell was deprecated in Ansible 2.11 and removed in Ansible 2.14. You can check the following resources for more information:

  • Deprecated features in Ansible 2.11.0 changelog.
  • Pull request which deprecated the feature in Ansible 2.11 (Credit to @U880D for the link)

The fact that the module reported in the error message is different from the one actually used is weird. I did not look into the issue but it looks like some display bug (to be confirmed)

The warn argument to shell was once a way to silence annoying warnings like:

You're using shell for XXX but there's a module for that. Are you sure you're not a bad boy?.

Checking those kind of good practice is done with ansible-lint nowadays and silencing warning there is done differently

In conclusion, you have 2 choices at this point:

  1. Downgrade to ansible-core 2.13.x. Since you are using the meta community package, the corresponding latest version is ansible 6.6.0 as you reported in your question.
  2. Remove all the warn entries on all shell tasks in your code. As explained above.
like image 56
Zeitounator Avatar answered Sep 13 '25 04:09

Zeitounator