Failed to parse the YAML fileANS-E9001Package installs should not use `latest`ANS-E4003`become_user` requires `become` to work as expectedANS-E5001Shells that use pipes should set the `pipefail` optionANS-E3006Use `command` instead of `shell`ANS-E3005Commands should not change things if nothing needs to be doneANS-E3001Should not use `command` instead of arguments to modulesANS-E3002Environment variables don't work as part of commandANS-E3004Use `module` instead of `command`ANS-E3003Relative path is not needed in roleANS-E4004Mercurial checkouts should have explicit revisionANS-E4002Git checkouts must contain explicit versionANS-E4001Found key duplicationANS-E9002Replace `local_action` with `delegate_to: localhost`ANS-E5004All tasks should be named uniquelyANS-E5002Referenced files must existANS-E5005Tasks that run when changed should likely be handlersANS-E5003
Commands should not change things if nothing needs to be doneANS-E3001
Tasks should tell Ansible when to return changed
, unless the task only reads information. To do this, set changed_when
, use the creates
or removes
argument, or use when
to run the task only if another check has a particular result.
Bad practice
- name: does not handle any output or return codes
ansible.builtin.command: cat {{ myfile|quote }}
Recommended
This snippet uses the output and the return code of the command.
- name: handle shell output with return code
ansible.builtin.shell: cat {{ myfile|quote }}
register: myoutput
changed_when: myoutput.rc != 0