Avoid Ansible command warning
Sometimes you need to execute a shell command on remote host, but Ansible gives you an annoying warning, for example:
[WARNING]: Consider using service module rather than running service
If it is a case when you absolutely need to use this command instead of running corresponding module, you can avoid getting this warning for the specific task with warn=false
parameter.
- name: get list of services without Ansible warning
shell: "service --status-all 2>&1 | awk {'print $4'}"
args:
warn: false # set warn=false to prevent warning
register: services_list