Ansible

Ansible

Made by DeepSource
All tasks should be named uniquely ANS-E5002
Anti-pattern
Minor

Task names are optional, but extremely useful. In its output, Ansible shows you the name of each task it runs. Choosing names that describe what each task does and why improves readability. It also enables the usage of --start-at-task.

Use command instead of shell ANS-E3005
Anti-pattern
Major

Use shell only when shell functionality is required. Shell should only be used when piping, redirecting or chaining commands (and Ansible would be preferred for some of those!)

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.

Relative path is not needed in role ANS-E4004
Anti-pattern
Major

copy and template do not need to use relative path for src. This removes the need for knowing the location of the root directory.

Tasks that run when changed should likely be handlers ANS-E5003
Anti-pattern
Minor

If a task has a when: result.changed setting, it is effectively acting as a handler. Sometimes you want a task to run only when a change is made on a machine. For example, you may want to restart a service if a task updates the configuration of that service, but not if the configuration is unchanged. Ansible uses handlers to address this use case. Handlers are tasks that only run when notified. Each handler should have a globally unique name.