Ansible

When running ansible or ansible-playbook commands you might encounter bright pink warning messages, perhaps stating a specific module has been deprecated. These messages are useful in alerting the team about technical debt or suboptimal code and should eventually refactor their code to use the new module.

You might not want these messages silenced or disabled.

However, there are certain messages that you might want to silence.

There might be a situations when you want to disable the Ansible warning that shows up for a particular task because it recommends something and in this case you cannot do it. For example, it recommends using the get_url module instead of using the shell module and running curl. In some cases the get_url module just doesn’t support the special curl command that you are performing.

Now, these warning messages are not impacting anything and are useful in most situations but at times can be annoying or distracting. So to disable them just use the following code example.

- name: Get all YUM repositories
  shell: 'yum repolist all -v'
  register: repos
  args:
    warn: false

- name: List contents of a folder
  shell: ls ./somedir
  args:
    warn: false