Ansible

Ansible

Made by DeepSource

Should not use command instead of arguments to modules ANS-E3002

Anti-pattern
Major

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

Recommended

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

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