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:
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:
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:
warn
entries on all shell tasks in your code. As explained above.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With