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

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

Problem Description:

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: 

Solution – 1

I was finally able to reproduce your above message with the latest ansible-core 2.14.0.

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.

Anyhow, 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?".

I can’t even find a reference to this parameter in the documentation anymore, I have no idea when it was actually deprecated and I’m quite sure it’s not of any use in any decently old and still supported version as checking good practice is done with ansible-lint nowadays and silencing warning there is done differently

In consclusion, 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 your reported in your question.
  2. Remove all the warn entries on all shell tasks in your code. As explained above, I’m quite sure it has not been of any use for quite a long time and you will have to do it anyway if you want to keep to speed with ansible development.
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject