Ansible logoAnsible/
ANS-E3002

Should not use `command` instead of arguments to modulesANS-E3002

Major severityMajor
Anti-pattern categoryAnti-pattern

Executing a command when there are arguments to modules is not recommended.

Using command module is a bad idea, since it’s not idempotent in nature, the developer is responsible for handling the idempotency of the task.

Bad practice

- name: restart nginx
  command: sudo systemctl restart nginx

It is better to use a service module with KV arguments.

- name: restart nginx
  service:
    name: nginx
    state: restarted