command
instead of arguments to modules ANS-E3002Executing 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.
- 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